fect
Estimate causal effects from staggered panel data by imputing counterfactual untreated outcomes from untreated cells and averaging observed-minus-imputed outcomes over treated cells.
Instructions
Counterfactual estimators for time-series cross-sectional data (Liu, Wang and Xu 2024): impute the untreated potential outcome of every treated unit-period from a model fitted on untreated cells only -- two-way fixed effects ('fe', the imputation estimator), interactive fixed effects with r factors ('ife'), or nuclear-norm matrix completion ('mc') -- and average Y - Y(0) over treated cells, with the ATT path by relative period. Native port of the R package fect; handles staggered adoption, many treated units, unbalanced panels and treatment reversals. Validation: certified evidence with scoped limitations. Known limitations: Inference is resampling-only (unit bootstrap or jackknife on request); the default returns point estimates only; r and lam are user-supplied; fect's cross-validated choice of r / lambda is not yet supported. Assumptions: Y(0) follows the chosen model (two-way FE / low-rank factors / low nuclear norm) on untreated cells; No anticipation and no carryover after treatment ends; Strict exogeneity of treatment status conditional on the fixed effects / factors. Pre-conditions: long panel with unit x time x outcome and a 0/1 treatment status; every retained unit has a...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| r | No | Number of latent factors (method='ife') | |
| y | Yes | Outcome column | |
| lam | No | Nuclear-norm penalty on fect's raw scale (method='mc'); the result records lambda_norm = lam / largest singular value. | |
| tol | No | EM relative convergence tolerance (fect default) | |
| vce | No | Resampling standard errors over units; None reports point estimates only. | |
| seed | No | Bootstrap seed | |
| time | Yes | Time period column | |
| unit | Yes | Unit identifier | |
| alpha | No | Significance level for confidence intervals and tests. | |
| force | No | Additive fixed effects in the Y(0) model. | two-way |
| treat | Yes | 0/1 treatment status in each unit-period (1 = treated) | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| method | No | Y(0) model: 'fe' two-way fixed effects, 'ife' interactive fixed effects with r factors, 'mc' matrix completion with penalty lam. | fe |
| min_t0 | No | Drop units with fewer untreated periods (fect: 1 for 'fe', 5 otherwise) | |
| n_boot | No | Bootstrap replications | |
| max_iter | No | Maximum EM iterations | |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| covariates | No | Time-varying covariates entering the Y(0) model linearly | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||