did_cluster_diagnostics
Counts treatment-assigned clusters and grades the count against published staggered DiD simulation evidence, flagging designs at or below 30 clusters where coverage is weak. Also reports clusters per cohort for group-time effects.
Instructions
Count the clusters treatment is assigned at and grade the count against the simulation grid of Ulloa-Perez et al. (2025), who found that at 30 clusters every modern staggered DiD estimator they evaluated under-covered a nominal 95% interval, with coverage improving as clusters accumulated. Thirty is the smallest cell they ran, so fewer clusters is reported as outside their evidence rather than as merely worse. Also reports clusters per cohort, since a group-time effect rests on the clusters in its own cohort. Assumptions: The grading reports what published simulation evidence exists at this cluster count; it is not a power calculation for this design or estimator. Pre-conditions: panel with unit and cohort columns. Failure modes: Cluster column empty or absent -> Check that the cluster column is populated. Alternatives: sp.wild_cluster_bootstrap, sp.ri_test, sp.conley.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unit | Yes | Unit identifier | |
| warn | No | Warn when the design sits in or below the weakest cell of the reference grid. | |
| 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 |
| cluster | No | Level treatment is assigned at (state, provider group, district). Defaults to unit with a warning: the two coincide only under independent unit-level assignment, and assuming so is the optimistic error. | |
| 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. | |
| first_treat | Yes | First-treatment period; 0 = never-treated | |
| 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 | |||