gsynth
Estimates causal treatment effects with generalized synthetic control using donor-pool comparisons, factor cross-validation, and placebo inference to support evidence-backed decisions.
Instructions
Generalized Synthetic Control via interactive fixed effects. Validation: certified parity evidence. Do NOT use when: there is only one treated unit and a short pre-period -- the interactive fixed-effects factors are not identified; use sp.synth; fewer pre-treatment periods than the number of factors being fit -- factor estimation is degenerate. Cost: Cross-validating n_factors refits the factor model cv_folds x max_factors times, and placebo/bootstrap inference refits again per replication -- runtime is multiplicative in those three knobs. Pin n_factors to skip the CV sweep. Assumptions: A convex (or regularized) combination of donor units reproduces the treated unit's pre-treatment outcome path; No interference: the treatment does not affect the donor units (SUTVA); No anticipation before the treatment date. Pre-conditions: Panel of one or more treated units plus an untreated donor pool, observed over time; Pre-treatment window long enough to fit donor weights (rule of thumb: more pre-periods than donors used); Outcome observed for every unit in every period. Failure modes: Large pre-treatment RMSPE -- the synthetic unit fails to track the treated unit before treatment -> Add don...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | Random seed. | |
| time | Yes | Time period column. | |
| unit | Yes | Unit identifier column. | |
| alpha | No | Significance level. | |
| 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 |
| backend | No | ``'native'`` uses StatsPAI's Python interactive fixed-effects implementation. ``'gsynth'``/``'r'`` delegates to the R ``gsynth`` package through ``Rscript`` using the Track-A reference specification ``force='two-way'``, ``CV=TRUE``, ``r=c(0, max_factors)``, and ``se=FALSE``. The R backend is intended for exact reference-package parity; the native path remains the dependency-light default. | native |
| outcome | Yes | Outcome variable name. | |
| placebo | No | Run placebo inference. | |
| cv_folds | No | Cross-validation folds for factor selection. | |
| 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://. | |
| n_factors | No | Number of latent factors. If None, selected by cross-validation. | |
| 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 | Additional time-varying covariates. | |
| max_factors | No | Maximum factors to try during CV. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| treated_unit | Yes | Identifier of the treated unit. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| treatment_time | Yes | First treatment period (inclusive). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||