Kappa trade-offs

Tabulate how each event-window choice (kappa_pre, kappa_post) affects the number of sub-experiments, sample sizes, and included cohorts — and, optionally, the outcome-free design-divergence screen D.

R kappa_trade_offs()   ↔︎   Stata stacked kappa

Usage

kappa_trade_offs(
  data, time_var, unit_var, adopt_var,
  kappa_pre_range = 0:5, kappa_post_range = 0:5,
  control_type = c("both", "never_treated", "not_yet_treated"),
  nyt_horizon = NULL, duck = FALSE, screen = FALSE,
  weight_type = c("unit_weights", "population_between", "pop_constant",
    "pop_total_periods", "pop_period_specific", "sample_share"),
  pop_var = NULL, weight_var = NULL,
  balance = c("as_is", "complete_window")
)

Arguments

Argument Description
data, time_var, unit_var, adopt_var As in build_stack().
kappa_pre_range, kappa_post_range Integer vectors of values to sweep (default 0:5).
control_type, nyt_horizon Control-group choices, as in build_stack().
screen If TRUE, add the design-divergence columns (D, etc.).
weight_type, pop_var, weight_var Mass basis for the screen (only used when screen = TRUE).
balance "as_is" (default) or "complete_window" (units observed at every event time).
duck Compute counts inside DuckDB — see DuckDB.
stacked kappa, time(varname) unit(varname) adopt(varname) ///
    [kpre(numlist) kpost(numlist) controltype(str) nythorizon(#) screen ///
     weighttype(str) popvar(varname) weightvar(varname) balance(str)]

Options

Option Description
time(), unit(), adopt() As in stacked build.
kpre(numlist), kpost(numlist) Value grids to sweep (e.g. kpre(1/4)).
controltype(str), nythorizon(#) Control-group choices.
screen Add the design-divergence columns and r(cohort_weights).
weighttype(str), popvar(varname), weightvar(varname) Mass basis for screen.
balance(str) as_is (default) or complete_window.

R ↔︎ Stata mapping

R Stata
kappa_pre_range / kappa_post_range kpre() / kpost() (numlists)
screen screen
weight_type / pop_var / weight_var weighttype() / popvar() / weightvar()
balance balance()
duck = TRUE parquet() — see DuckDB

Value / Stored results

R returns a data.table, one row per (kappa_pre, kappa_post): n_sub_exp (identified cohorts, matching build_stack()), n_unidentified_sub_exp, n_event_times, n_obs, total_treated_obs, total_control_obs, per-period averages/SDs, and adoption_times_str. With screen = TRUE it adds D, n_valid_sub_exp, n_dropped_sub_exp, min_control_mass, max_treated_share, top_gap_cohort, and a cohort_weights attribute.

Stata stores the full grid in r(table); with screen, the per-cohort masses and weight vectors in r(cohort_weights).

The screen measures \(D_\kappa = \sum_a |w_a^S - w_a^T|\), the total-variation gap between the precision weights an unweighted stacked regression implies and the treated-mass target weights. It is computable before any outcome is seen: near-zero D means weighting cannot matter; large D flags exposure to effect heterogeneity.

Example

library(stacked)
data(medicaid)

# sample-size trade-offs
kt <- kappa_trade_offs(
  medicaid, "year", "state", "adopt_year",
  kappa_pre_range = 1:3, kappa_post_range = 1:3
)
kt[, .(kappa_pre, kappa_post, n_sub_exp, n_obs)]
   kappa_pre kappa_post n_sub_exp n_obs
1:         1          1         5   354
2:         1          2         4   400
3:         1          3         3   425
4:         2          1         5   472
5:         2          2         4   500
6:         2          3         3   510
7:         3          1         5   590
8:         3          2         4   600
9:         3          3         3   595
# outcome-free design screen
sc <- kappa_trade_offs(
  medicaid, "year", "state", "adopt_year",
  kappa_pre_range = 2:3, kappa_post_range = 2:3,
  screen = TRUE
)
sc[, .(kappa_pre, kappa_post, D, n_valid_sub_exp, top_gap_cohort)]
   kappa_pre kappa_post         D n_valid_sub_exp top_gap_cohort
1:         2          2 0.3125317               4           2014
2:         2          3 0.2652806               3           2014
3:         3          2 0.3125317               4           2014
4:         3          3 0.2652806               3           2014
stacked use medicaid, clear
stacked kappa, time(year) unit(state) adopt(adopt_year) kpre(1/4) kpost(1/4)

* with the outcome-free design screen
stacked kappa, time(year) unit(state) adopt(adopt_year) ///
    kpre(2/3) kpost(2/3) screen

See also