Skip to contents

Splits df on year_col and fits morie_otis_irm_dml in each year. With full_battery = TRUE each year instead gets IPW, AIPW, g-computation, PSM 1:1, PSM subclassification, ATC, PLR, SuperLearner AIPW, IRM-DML and PSM-then-IRM-DML. A year whose fit fails records the error message rather than stopping the others.

Usage

morie_otis_per_year_irm_dml(
  df,
  treatment,
  outcome,
  covariates,
  year_col = "EndFiscalYear",
  cluster_cols = NULL,
  n_folds = 3L,
  seed = 123L,
  full_battery = FALSE
)

Arguments

df

A data frame.

treatment

Binary treatment column name.

outcome

Outcome column name.

covariates

Character vector of covariate names.

year_col

Column to split on (default "EndFiscalYear").

cluster_cols

NULL, a single column name, or a length-2 character vector for two-way clustering.

n_folds

Number of cross-fitting folds (default 3).

seed

Integer seed (default 123).

full_battery

Logical; run every estimator per year.

Value

Named list keyed by year.

Examples

set.seed(1)
n <- 400L
x <- rnorm(n)
d <- rbinom(n, 1, plogis(0.4 * x))
df <- data.frame(d = d, y = 0.5 * d + x + rnorm(n), x = x,
                 yr = rep(2023:2024, each = n / 2))
sapply(morie_otis_per_year_irm_dml(df, "d", "y", "x", year_col = "yr"),
       `[[`, "ate")
#>      2023      2024 
#> 0.7487630 0.3131366