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"),
  cells       = NULL,
  weights     = NULL,
  window      = NULL,
  direction   = c("on", "off"),
  vartype     = c("bootstrap", "jackknife", "parametric", "none"),
  conf.level  = 0.95,
  ci.method   = c("basic", "percentile")
)

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.

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), which may differ from this argument value if the fit was produced with a different setting — the argument is informational and does not re-aggregate replicates.

conf.level

Two-sided confidence level. Defaults to 0.95.

ci.method

"basic" (reflected; matches fect's existing est.att convention; default) or "percentile".

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 April 30, 2026, 9:06 a.m.