View source: R/weighting_functions.R
kw.mob | R Documentation |
This function computes KW pseudo-weights using model-based recursive partitioning
(glmtree()
in partykit
package) to predict propensity scores.
kw.mob( psa_dat, wt, rsp_name, formula, tune_maxdepth, covars, h = NULL, krn = "triang", large = F, rm.s = F )
psa_dat |
Dataframe of the combined non-probability and probability sample |
wt |
Name of the weight variable in |
rsp_name |
Name of the non-probability sample membership indicator in |
formula |
Formula of the propensity model
(see |
tune_maxdepth |
A vector of values for the tuning parameter maxdepth
(see |
covars |
A vector of covariate names for standardized mean differences (SMD; covariate balance) calculation |
h |
Bandwidth parameter (will be calculated corresponding to kernel function if not specified) |
krn |
Kernel function.
" |
large |
The cohort size is so large that it has to be divided into pieces. Default is |
rm.s |
Remove unmatched survey units or not. Default is |
A list
pswt
: A dataframe including KW pseudo-weights for each tuning parameter setting
smds
: A vector of SMD for each set of KW pseudo-weights
best
: Identifier for the KW pseudo-weights in pswt with the smallest SMD
p_score_c
: A dataframe including propensity scores for non-probability sample units
for each tuning parameter setting
p_score_s
: A dataframe including propensity scores for probability sample units
for each tuning parameter setting
# KW-MOB with example data kwmob <- kw.mob(simu_dat, "wt", "trt", "trt_f ~ x1+x2+x3+x4+x5+x6+x7 | x1+x2+x3+x4+x5+x6+x7", tune_maxdepth = c(2, 3), covars = c("x1","x2","x3","x4","x5","x6","x7")) # Select KW-MOB pseudo-weights with best covariate balance kwmob_w <- kwmob$pswt[, kwmob$best] # Compute weighted mean of y in non-prob data sum((simu_dat$y[simu_dat$trt == 1]*kwmob_w)/sum(kwmob_w))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.