Skip to contents

Estimates the ATE by: $$\widehat{ATE} = \frac{1}{n}\sum_i \bigl[\hat{\mu}_1(X_i) - \hat{\mu}_0(X_i)\bigr]$$

Usage

morie_estimate_g_computation(
  data,
  treatment,
  outcome,
  covariates,
  outcome_model = c("linear", "logistic")
)

Arguments

data

A data frame.

treatment

Name of the binary treatment column.

outcome

Name of the outcome column.

covariates

Character vector of covariate names.

outcome_model

Family for the outcome model: "linear" or "logistic".

Value

Named list: ate, se, ci_lower, ci_upper.

Details

Delegates the standardisation step to stdReg::stdGlm() when stdReg is installed; otherwise computes the contrast inline from a single stats::glm() fit with treatment-flipped counterfactual datasets.

Examples

set.seed(1)
df <- data.frame(t = rbinom(200, 1, 0.4), y = rnorm(200), x = rnorm(200))
morie_estimate_g_computation(df, "t", "y", "x")
#> $ate
#> [1] -0.06093144
#> 
#> $se
#> [1] 0.1419764
#> 
#> $ci_lower
#> [1] -0.3392052
#> 
#> $ci_upper
#> [1] 0.2173424
#>