Skip to contents

Designed-experiment convenience wrapper around the morie causal estimator family

Usage

mrm_causal_design(
  data,
  treatment_col,
  outcome_col,
  covariates = character(0),
  estimator = c("ipw", "diff_in_means")
)

Arguments

data

data.frame with treatment, outcome, optional covariates.

treatment_col

Binary 0/1 treatment column.

outcome_col

Continuous outcome column.

covariates

Optional character vector of covariate columns.

estimator

One of "ipw" (Hajek IPW with logistic propensity), "diff_in_means" (no adjustment).

Value

Named list with estimator, estimate, se, ci_lower, ci_upper, p_value, n, n_treated, interpretation.

Examples

set.seed(2026)
n <- 200L
x <- rnorm(n)
D <- rbinom(n, 1, plogis(0.5 * x))
y <- 0.7 * D + 0.3 * x + rnorm(n, 0, 0.5)
df <- data.frame(D = D, y = y, age = x)
# IPW-adjusted ATE
ipw <- mrm_causal_design(df,
  treatment_col = "D",
  outcome_col = "y",
  covariates = "age",
  estimator = "ipw"
)
# Naive difference in means for comparison
raw <- mrm_causal_design(df,
  treatment_col = "D",
  outcome_col = "y",
  estimator = "diff_in_means"
)
c(ipw = ipw$estimate, raw = raw$estimate)
#>      ipw      raw 
#> 0.649974 0.909346