Trims (i.e., truncates) large weights by setting all weights higher than that at a given quantile to the weight at the quantile. This can be useful in controlling extreme weights, which can reduce effective sample size by enlarging the variability of the weights.
trim.wimids() works by calling
WeightIt::trim() on each
weightit object stored in the
models component of the
wimid object. Because
trim() itself is not exported from MatchThem, it must be called using
WeightIt::trim() or by attaching WeightIt (i.e., running
library(WeightIt)) before use. See Example.
An object of class
wimids, identical to the original object except with
trim() applied to each of the
weightit objects in the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#Loading libraries library(MatchThem) #Loading the dataset data(osteoarthritis) #Multiply imputing the missing values imputed.datasets <- mice::mice(osteoarthritis, m = 5) #Estimating weights of observations in the multiply imputed datasets weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK, imputed.datasets, approach = 'within', method = 'ps', estimand = "ATE") #Trimming the top 10% of weights in each dataset #to the 90th percentile trimmed.datasets <- trim(weighted.datasets, at = .9)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.