Estimate Treatment Effect using Marginal Standardization (G-Computation)
Source:R/standardization.R
standardization.RdCompute an estimate of a marginal treatment effect using marginal standardization, also known as standardization or G-computation.
Usage
standardization(
data,
outcome_formula = NULL,
outcome_formula_treatment = NULL,
outcome_formula_control = NULL,
family,
estimand = "difference",
treatment_column = NULL,
se_method = c("none", "influence", "score", "bootstrap")[1],
alpha = 0.05,
bootstrap_parameters = impart::boot_control(),
bootstrap_ci_method = "bca",
variance_adjustment = standardization_df_adjust_tsiatis_2008,
influence_function = standardization_influence,
verbose = FALSE
)
standardization_fit(
data,
outcome_formula = NULL,
outcome_formula_treatment = NULL,
outcome_formula_control = NULL,
family,
treatment_column,
predictors,
estimand,
verbose
)
standardization_influence(
y = NULL,
a = NULL,
y_pred = NULL,
y1_pred = NULL,
y0_pred = NULL,
estimand,
model_type,
has_intercept,
has_treatment_interaction
)
standardization_df_adjust_tsiatis_2008(
data,
outcome_formula = NULL,
outcome_formula_treatment = NULL,
outcome_formula_control = NULL,
estimand,
treatment_column
)Arguments
- data
A
data.framecontaining the data to be analyzed.- outcome_formula
A
formulawhich includes treatment as a main effect. To use treatment-stratified outcome models, leave this argumentNULL.- outcome_formula_treatment
A
formulafor a regression model fit to participants in the treatment arm. If using a single model with regression parameters for treatment assignment, leave this argumentNULL.- outcome_formula_control
A
formulafor a regression model fit to participants in the control arm. If using a single model with regression parameters for treatment assignment, leave this argumentNULL.- family
The
familyfor the regression model(s) being fit. See?family.- estimand
A
characterscalar, indicating the estimand to be returned:"difference"for a difference in means (or risk difference);"ratio"for a ratio of means (or relative risk), or"oddsratio"for an odds ratio.- treatment_column
A
characterscalar indicating the column that contains the binary indicator of treatment assignment.- se_method
A
characterscalar, indicating the method for computing standard errors:"none"for no standard errors;- alpha
Confidence level for computing interval estimates. This is only used when
se_method != "none".- bootstrap_parameters
A
listof parameters to be passed toboot::boot()when computing bootstrap standard errors and confidence intervals. See?boot::boot(). This is only used whense_method == "bootstrap".- bootstrap_ci_method
A
characterscalar, specifying the type of interval estimates to compute. See?boot::boot(). This is only used whense_method == "bootstrap".- variance_adjustment
A
functionfor computing a finite-sample variance adjustment for degrees of freedom in model fitting.- influence_function
A
functionfor computing the influence function of each observation, which can be used for variance and covariance calculations.- verbose
A
logicalscalar: ifFALSE, only results are returned; ifTRUE, additional objects used to construct the estimate are also returned.- predictors
A
charactervector containing the names of covariates: used to check for missing values to be imputed.- y
A
numericvector containing the outcome values.- a
A
numericvector containing the binary treatment assignment indicator.- y_pred
A
numericvector containing the model-predicted value of the outcome under the observed treatment assignment.- y1_pred
A
numericvector containing the model-predicted value of the outcome under assignment to treatment.- y0_pred
A
numericvector containing the model-predicted value of the outcome under assignment to control.- model_type
A
characterscalar: either "stratified" or "single" model, used to indicate the analysis approach- has_intercept
A
logicalscalar, indicating whether an intercept term is included in the model.- has_treatment_interaction
A
logicalscalar, indicating whether treatment-by-covariate interactions are included in the model.
Value
Depending on the options specified, a numeric scalar
containing the estimate, a data.frame containing estimates, standard
errors, and confidence intervals, or a list additionally containing
objects used in constructing the estimates.
Details
Marginal standardization can be viewed as a generalization of the ANCOVA estimate: the estimated treatment effect will coincide with ANCOVA when a single outcome model with an identity link is fit using a functional form where treatment assignment only appears as a main effect (i.e. no treatment-by-covariate interactions).
Outcome regressions can include a single generalized linear model, or two treatment-stratified generalized linear models. Variance estimates can be obtained through the nonparametric bootstrap. Variance estimation using the influence or score function can also be obtained for certain estimands and outcome models.
standardization should be used: this checks inputs, and calls
standardization_fit: the latter has been streamlined to speed up
the nonparametric bootstrap.
Examples
impart::standardization(
data = example_1,
outcome_formula = y_4 ~ x_1 + x_2 + x_3 + x_4 + tx,
family = gaussian(link = "identity"),
estimand = "difference",
treatment_column = "tx",
se_method = "influence"
)
#> estimate se_influence lcl_influence_0.95 ucl_influence_0.95 estimand
#> 1 3.302204 1.147582 1.052984 5.551424 difference
#> variance_factor
#> 1 1.022422
impart::standardization(
data = example_1,
outcome_formula = y_4 ~ x_1 + x_2 + x_3 + x_4 + tx,
family = gaussian(link = "identity"),
estimand = "difference",
treatment_column = "tx",
se_method = "score"
)
#> estimate se_score lcl_score_0.95 ucl_score_0.95 estimand variance_factor
#> 1 3.302204 1.152525 1.043296 5.561112 difference 1.022422