| balancing.weights | R Documentation |
This function calculates balancing weights based on the specified pseudo-population method.
balancing.weights(
S,
Z,
X,
method,
naturalGroupProp,
num.random = 40,
gammaMin = 0.001,
gammaMax = (1 - 0.001),
seed = NULL,
verbose = TRUE,
suppress_diagnostics = FALSE,
nodesize = NULL,
fold_ids = NULL
)
S |
Vector of factor levels representing the study memberships. Takes values in {1, ..., J}. |
Z |
Vector of factor levels representing the group memberships. Takes values in {1, ..., K}. |
X |
Covariate matrix of |
method |
Pseudo-population method, i.e., weighting method. Take values in |
naturalGroupProp |
Relevant only for FLEXOR method: a fixed user-specified probability vector |
num.random |
Relevant only for FLEXOR method: number of random starting points of |
gammaMin |
Relevant only for FLEXOR method: Lower bound for each |
gammaMax |
Relevant only for FLEXOR method: Upper bound for each |
seed |
Seed for random number generation. Default is |
verbose |
Logical; Relevant only for FLEXOR method: if |
suppress_diagnostics |
Logical; if TRUE, suppress diagnostic warnings (default: FALSE). Used internally during bootstrapping to avoid console clutter. |
nodesize |
Integer nodesize for the propensity score random forests; if |
fold_ids |
Integer vector of cross-fitting fold assignments (length N); if |
Propensity scores are estimated with a joint (S, Z) random forest, fit to a truncated SVD reconstruction of the unscaled covariates that retains 60% of the cumulative singular values.
An S3 object of class balancing_weights with the following components:
N empirically normalized sample weights.
Percentage sample effective sample size (ESS) for the pseudo-population.
Weighting method used (FLEXOR, IC, or IGO).
Selected min.node.size for the propensity forest.
A list of propensity model diagnostics:
frac_truncated: Fraction of subjects with own-cell propensity
below the truncation floor prior to stabilization.
crossfit_accuracy: Out-of-fold classification accuracy of the
propensity model (NA during bootstrap).
max_weight: Maximum weight prior to normalization.
prob_quantiles: Quantiles of the subject-level propensity
distribution.
data(demo)
# IC Method
weights_ic <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp)
summary(weights_ic)
# IGO Method
weights_igo <- balancing.weights(S, Z, X, method = "IGO", naturalGroupProp)
summary(weights_igo)
# FLEXOR Method
weights_flexor <- balancing.weights(S, Z, X, method = "FLEXOR", naturalGroupProp, num.random = 40)
summary(weights_flexor)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.