| causal.estimate | R Documentation |
This function estimates causal effects based on the specified pseudo-population method. The FLEXOR method involves an iterative two-step procedure.
causal.estimate(
S,
Z,
X,
Y,
B = 0,
method,
naturalGroupProp = NULL,
num.random = 40,
gammaMin = 0.001,
gammaMax = (1 - 0.001),
seed = NULL,
verbose = TRUE,
parallel = FALSE,
n_cores = NULL,
outcome_model = FALSE,
crossfit_folds = 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 |
Y |
Matrix of |
B |
Number of bootstrap samples for variance estimation. Default is 0 (point estimates only). |
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; if |
parallel |
Logical; if TRUE, use parallel processing for bootstrap (default: FALSE) |
n_cores |
Number of cores to use for parallel bootstrap (default: availableCores() - 1). Only used if parallel = TRUE. |
outcome_model |
Logical; if TRUE, fits a random forest on X, S, Z and substitutes predicted outcomes for observed Y. Default FALSE. |
crossfit_folds |
Integer >= 2 for K-fold cross-fitting of the outcome model, or NULL (default) to fit on the full data. Only used when |
An S3 object of class causal_estimates with the following
components:
Percentage sample ESS of the pseudo-population.
Array of dimension 3 \times K \times L: estimated
means, SDs, and medians (dim 1) for K groups (dim 2) and L
outcomes (dim 3).
Estimated mean group differences for L
outcomes.
Array of dimension 3 \times K \times L
\times B: moments.ar for each of B bootstrap samples
(only present when B > 0).
Matrix of dimension L \times B:
otherFeatures.v for each of B bootstrap samples (only
present when B > 0).
Vector of length B: percentage sample ESS for
each bootstrap sample (only present when B > 0).
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.
max_weight: Maximum weight prior to normalization.
prob_quantiles: Quantiles of the subject-level propensity
distribution.
data(demo)
# Point estimates only (no CIs)
result <- causal.estimate(S, Z, X, Y, B = 0, method = "IC", naturalGroupProp)
summary(result)
# Bootstrap CIs
set.seed(1)
result <- causal.estimate(S, Z, X, Y, B = 100, method = "IC", naturalGroupProp)
summary(result)
plot(result)
# FLEXOR method
result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp,
num.random = 40, seed = 1)
# Outcome model: substitute RF predictions for observed Y
result <- causal.estimate(S, Z, X, Y, B = 0, method = "FLEXOR", naturalGroupProp,
outcome_model = TRUE)
# Parallel bootstrap
result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp,
parallel = TRUE, n_cores = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.