| imputed_outcomes | R Documentation |
Returns the cell-level imputed potential-outcome surface from a fitted
fect object as a long-form data frame. This is the rock-bottom
accessor for any post-hoc estimand: read off the columns and aggregate
however you like. Used internally by estimand for the
shipped estimand types; exposed publicly so users can compose custom
estimands the package does not ship.
imputed_outcomes(
fit,
cells = NULL,
replicates = FALSE,
direction = c("on", "off")
)
fit |
A |
cells |
Optional filter on which treated cells to return. Accepts
|
replicates |
Logical. |
direction |
Either |
A data frame with one row per treated cell or per (treated cell, replicate). Columns:
idUnit identifier from fit$id.
timeCalendar time from fit$rawtime.
event.timeEvent time at this cell (relative to onset
or exit per direction).
cohortFirst-treatment calendar time for the unit
(direction = "on") or first-exit calendar time
(direction = "off").
treatedLogical; always TRUE in returned rows.
Y_obsObserved outcome at this cell.
Y0_hatImputed counterfactual outcome
(Y_obs - eff).
effCell-level score: contribution to the ATT estimator.
For imputation estimators this equals Y_obs - Y0_hat; for
doubly-robust estimators it equals
(Y_obs - Y0_hat) + eff_debias.
eff_debiasDebias correction; 0 for plain imputation estimators, populated for DR estimators.
W.aggAggregation weight at this cell; 1 if the fit
was built without W or W.agg.
replicate(only when replicates = TRUE)
1..nboots for bootstrap, or the dropped-unit index for
jackknife.
With replicates = TRUE the returned data frame has
n_treated_cells * nboots rows. For typical panels this is
manageable; for large panels (TT \times N \ge 50{,}000 and
nboots \ge 500) consider filtering via cells
before expansion.
This function reads from fit$Y.dat, fit$D.dat,
fit$T.on (or T.off), fit$eff,
fit$eff.boot (when replicates = TRUE),
fit$eff_debias (when populated), fit$W.agg,
fit$id, fit$rawtime. These slots have a documented
stable shape; see the package design notes.
estimand for the typed dispatcher built on top of this
accessor; fect for the fitting interface.
## 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,
keep.sims = TRUE)
## Point-estimate long form: one row per treated cell.
po <- imputed_outcomes(fit)
head(po)
## Filter to first 5 event times.
po5 <- imputed_outcomes(fit, cells = ~ event.time %in% 1:5)
## Bootstrap replicate expansion (requires keep.sims = TRUE).
po_b <- imputed_outcomes(fit, replicates = TRUE)
nrow(po_b) == nrow(po) * 200 # one row per (cell, replicate)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.