estimand: Post-hoc Estimand Dispatcher

View source: R/po-estimands.R

estimandR Documentation

Post-hoc Estimand Dispatcher

Description

Computes a post-hoc estimand from a fect fit, with bootstrap or jackknife uncertainty. The type argument selects from a closed enum of mathematically-defined estimands; the by argument selects the grouping axis. The accessor imputed_outcomes is the underlying long-form data source for any estimand the dispatcher does not ship natively.

Usage

estimand(
  fit,
  type   = c("att", "att.cumu", "aptt", "log.att"),
  by     = c("event.time", "cohort", "calendar.time", "overall"),
  test        = c("none", "placebo", "carryover"),
  cells       = NULL,
  weights     = NULL,
  window      = NULL,
  direction   = c("on", "off"),
  vartype     = c("bootstrap", "jackknife", "parametric", "none"),
  conf.level  = 0.95,
  ci.method   = NULL
)

Arguments

fit

A fect object.

type

Estimand type. "att" returns per-cell mean treatment effect aggregated per group; "att.cumu" returns cumulative ATT through each event time (replaces effect); "aptt" returns the average proportional treatment effect on the treated (Chen and Roth 2024 QJE); "log.att" returns the mean log-scale treatment effect. "aptt" and "log.att" require keep.sims = TRUE at fit time for SE/CI.

by

Grouping axis. One of "event.time" (default), "cohort", "calendar.time", "overall", or any column name resolvable in the fit's panel data.

test

Selects which subset of cells to aggregate over. "none" (default) uses the standard treated post-treatment cells. "placebo" restricts aggregation to the pre-treatment cells in fit$placebo.period that were masked-and-imputed during the placebo fit; e.g.\ estimand(fit, "aptt", "event.time", test = "placebo") returns a per-event-time placebo APTT series. Requires placeboTest = TRUE at fit time and forces direction = "on". "carryover" is the analogous extension for early post-reversal cells in fit$carryover.period; requires carryoverTest = TRUE at fit time, a panel with reversals, and forces direction = "off". Both are incompatible with type = "att.cumu".

cells

Optional filter on which treated cells to include. Accepts NULL (default), a logical vector, or a one-sided formula. See imputed_outcomes.

weights

Aggregation-weight handling. NULL (default) uses fit$W.agg if the fit was built with W or W.agg; otherwise uniform.

window

Optional event-time window c(L, R); convenience sugar for cells = ~ event.time >= L & event.time <= R.

direction

Either "on" (default) or "off"; see imputed_outcomes.

vartype

"bootstrap" (default), "jackknife", "parametric", or "none". Selects which variance method to source replicates from. The output vartype column reports the method actually used at fit time (read from fit$vartype); this argument is informational and does not re-aggregate replicates. Wild-bootstrap fits (vartype = "wild" at fit time) are consumed transparently and reported as "wild" in the output column.

conf.level

Two-sided confidence level. Defaults to 0.95.

ci.method

One of "basic", "percentile", "bc" (bias-corrected percentile), "bca" (bias-corrected accelerated; Efron 1987 in full), or "normal" (Wald: \hat\theta \pm z \cdot SE). Default is NULL, which triggers a per-type default: "att" -> "normal" (matches what fit$est.att already uses internally), "att.cumu" -> "percentile" (matches what att.cumu() does internally), "aptt" -> "bca" and "log.att" -> "bca" (ratio / log estimators benefit from joint bias and acceleration corrections when the bootstrap distribution is skewed; "bc" can degenerate at the boundary when the point estimate falls outside the bootstrap support). Pass an explicit value to override. "bca" requires bootstrap- or wild-bootstrap-sourced replicates.

Value

A data frame with columns <by_key>, estimate, se, ci.lo, ci.hi, n_cells, and vartype. Always tidy regardless of type or by.

Numerical equality with existing slots

estimand(fit, "att", "event.time") returns estimate, se, ci.lo, ci.hi byte-identical to columns ATT, S.E., CI.lower, CI.upper of fit$est.att, when default arguments are used. This invariant is asserted by package tests.

References

Chen, Jiafeng, and Jonathan Roth. 2024. "Logs with Zeros? Some Problems and Solutions." Quarterly Journal of Economics 139 (2): 891–936.

See Also

imputed_outcomes for the underlying long-form accessor; fect for the fitting interface.

Examples

## Not run: 
library(fect)
fit <- fect(Y ~ D, data = simdata, index = c("id", "time"),
            method = "fe", force = "two-way",
            se = TRUE, nboots = 200, parallel = FALSE)

## Default: per-event-time ATT (matches fit$est.att numerically).
est <- estimand(fit, "att", "event.time")
head(est)

## End(Not run)

fect documentation built on May 31, 2026, 1:06 a.m.