Skip to contents

Compute 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.frame containing the data to be analyzed.

outcome_formula

A formula which includes treatment as a main effect. To use treatment-stratified outcome models, leave this argument NULL.

outcome_formula_treatment

A formula for a regression model fit to participants in the treatment arm. If using a single model with regression parameters for treatment assignment, leave this argument NULL.

outcome_formula_control

A formula for a regression model fit to participants in the control arm. If using a single model with regression parameters for treatment assignment, leave this argument NULL.

family

The family for the regression model(s) being fit. See ?family.

estimand

A character scalar, 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 character scalar indicating the column that contains the binary indicator of treatment assignment.

se_method

A character scalar, 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 list of parameters to be passed to boot::boot() when computing bootstrap standard errors and confidence intervals. See ?boot::boot(). This is only used when se_method == "bootstrap".

bootstrap_ci_method

A character scalar, specifying the type of interval estimates to compute. See ?boot::boot(). This is only used when se_method == "bootstrap".

variance_adjustment

A function for computing a finite-sample variance adjustment for degrees of freedom in model fitting.

influence_function

A function for computing the influence function of each observation, which can be used for variance and covariance calculations.

verbose

A logical scalar: if FALSE, only results are returned; if TRUE, additional objects used to construct the estimate are also returned.

predictors

A character vector containing the names of covariates: used to check for missing values to be imputed.

y

A numeric vector containing the outcome values.

a

A numeric vector containing the binary treatment assignment indicator.

y_pred

A numeric vector containing the model-predicted value of the outcome under the observed treatment assignment.

y1_pred

A numeric vector containing the model-predicted value of the outcome under assignment to treatment.

y0_pred

A numeric vector containing the model-predicted value of the outcome under assignment to control.

model_type

A character scalar: either "stratified" or "single" model, used to indicate the analysis approach

has_intercept

A logical scalar, indicating whether an intercept term is included in the model.

has_treatment_interaction

A logical scalar, 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.007589           1.327365           5.277042 difference

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
#> 1 3.302204 1.011929        1.31886       5.285548 difference