econometric-diagnostics
Diagnose and stress-test an estimated econometric model (panel, time series or cross section) in Python. Replicates the user's baseline, runs the specification and diagnostic tests that fit the data structure, decides the appropriate inference, runs a one-change-at-a-time robustness battery, and writes LaTeX tables plus an interpreted report with a methodology paragraph. Use when the user asks to validate, diagnose, check the robustness of, or report the tests for a regression they have estimated (statsmodels, linearmodels, or a Stata/R model that can be re-expressed as a formula).
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/matheusrwh--econometric-diagnostics)HTML
<a href="/listings/matheusrwh--econometric-diagnostics"><img src="/api/listings/matheusrwh--econometric-diagnostics/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
git clone https://github.com/<user>/econometric-diagnostics ~/.claude/skills/econometric-diagnostics pip install -r ~/.claude/skills/econometric-diagnostics/requirements.txt
Then, in Claude Code, inside your research project:
> Check the robustness of the models in `models/baseline.py`.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
SKILL.md · Manifest · 116 lines
- ---
- name: econometric-diagnostics
- description: Diagnose and stress-test an estimated econometric model (panel, time series or cross section) in Python. Replicates the user's baseline, runs the specification and diagnostic tests that fit the data structure, decides the appropriate inference, runs a one-change-at-a-time robustness battery, and writes LaTeX tables plus an interpreted report with a methodology paragraph. Use when the user asks to validate, diagnose, check the robustness of, or report the tests for a regression they have estimated (statsmodels, linearmodels, or a Stata/R model that can be re-expressed as a formula).
- ---
- # Econometric diagnostics and robustness
- You are acting as a careful applied econometrician reviewing a colleague's model before
- submission. The scripts compute; **you** decide which tests matter, what they imply and
- what to recommend. Never let the scripts' flags replace reading the numbers.
- ## Ground rules
- 1. **Do not modify the user's code or data.** Everything you write goes to
- `<project>/reports/diagnostics/<model_set>/` (or a folder the user names).
- 2. **Replicate before you diagnose.** The baseline must reproduce the user's own
- coefficients, standard errors and N. If it does not, stop and reconcile the sample
- (filters, exclusions, missing values, inf values) before running anything else.
- 3. **Decide the inference before you look at robustness.** Choose the recommended standard
- errors and estimator from the diagnostic tests (step 4), write that decision down, and
- only then run the robustness battery. Never recommend a variant because it is
- significant.
- 4. **Report everything you ran**, including variants that weaken the result.
- 5. **Robustness is not heterogeneity.** A coefficient that differs between sub-periods may be
- the finding (parameter change), not a failure. Say which is which.
- 6. **No causal language the design cannot support.** Diagnostics test statistical
- assumptions; they do not make an OLS/FE coefficient causal.
- ## Scripts (in `scripts/`, run with `python <script> <config.json>`)
- | Script | Structure | What it does | Output |
- |---|---|---|---|
- | `inspect_data.py` | all | structure, N, T, balance, gaps, missing/inf, extreme values, within-variation share | `inspection.json` |
- | `panel_diagnostics.py` | panel | F entity/time effects, BP-LM, Hausman, Mundlak, Wooldridge AR(1), modified Wald, Pesaran CD, Fisher-ADF unit roots, VIF, outliers; `--skip-unit-root` | `panel_diagnostics.json` |
- | `robustness.py` | panel | baseline + inference / estimator / sample variants + leave-one-entity-out jackknife + verdict; `--no-jackknife` | `robustness.json` |
- | `ols_diagnostics.py` | time series, cross section | diagnostics **and** robustness for OLS | `ols_diagnostics.json` |
- | `to_latex.py` | all | booktabs tables; `--lang en` or `--lang pt` | `table_diagnostics.tex`, `table_robustness.tex` |
- Requirements: `pandas numpy scipy statsmodels linearmodels patsy` (see `requirements.txt`).
- Use the project's own environment if it has them; otherwise ask before installing anything.
- The jackknife refits the model once per entity (about 1 s per fit for a two-way FE panel
- with ~3,000 obs); use `--no-jackknife` while iterating and run the full battery once.
- ## Workflow
- ### 1. Understand the model
- Read the user's estimation script (or ask for the specification). Extract:
- data file, entity and time identifiers, sample filters and exclusions, the formula for each
- model, fixed effects, covariance type, and the **key coefficient(s)** the paper is about.
- Note the reported results (table or `.txt` output) — you need them for step 2.
- ### 2. Write the config and replicate
- Create `config.json` in the output folder; the schema is in
- `references/config_schema.md`. Run `inspect_data.py`, then confirm that N per model matches
- the user's results. The `Baseline` row of `robustness.py` (or `ols_diagnostics.py`) must
- reproduce their coefficient and standard error to the reported precision. If it does not,
- fix the config — never proceed with a baseline that differs from the paper.
- Also read `inspection.json` for: unbalancedness, entities with gaps, regressors with low
- within variation (FE will be imprecise), and heavy tails (excess kurtosis, values beyond
- 5×IQR).
- ### 3. Run the diagnostics
- - Panel: `panel_diagnostics.py config.json`
- - Time series / cross section: `ols_diagnostics.py config.json` (includes robustness)
- ### 4. Interpret and decide
- Open `references/decision_tree.md` and walk through it **with the actual numbers** for every
- model. For each test, read `references/interpretation.md` before drawing conclusions —
- several tests are invalid or uninformative in specific settings (classic Hausman under
- clustering, Pesaran CD after time effects, clustered Wald with more restrictions than
- clusters, panel unit-root tests under cross-sectional dependence).
- Write down, before step 5:
- - the recommended estimator (pooled / RE / FE entity / FE two-way / FD) and why;
- - the recommended standard errors and why;
- - what the baseline in the paper gets right and what it should change.
- ### 5. Run the robustness battery (panel)
- `robustness.py config.json`. Each variant changes exactly one thing relative to the
- baseline (see the script docstring). Read the verdict per key coefficient:
- - `ROBUST` — same sign, still significant, and within ±50 % of the baseline in every
- robustness variant; no jackknife sign change.
- - `MOSTLY ROBUST` — same sign everywhere, but some variant loses significance or moves more
- than 50 %. Name the variants and explain them.
- - `FRAGILE` — a sign flip in a robustness variant or in the jackknife.
- - `HETEROGENEITY` lines list sub-samples where the coefficient differs by more than 30 %:
- discuss them as substantive findings or as a reason to model the change explicitly.
- Rows marked `[info]` (pooled OLS, between) answer a different question and do not count
- for the verdict; use them to discuss whether the relation is mainly within or between
- entities.
- ### 6. Tables
- `to_latex.py config.json --lang <en|pt>` — match the language of the paper. The tables need
- `booktabs` and `graphicx`. Point the user to `\input{...}` paths.
- ### 7. Report
- Write `report.md` in the output folder following `templates/report_template.md`, in the
- user's language. It must contain: verdict up front, a diagnostics table read in plain
- words, the decision on inference/estimator with justification, the robustness summary,
- the heterogeneity discussion, concrete recommendations for the paper (what to change, what
- to add to the appendix), a ready-to-paste methodology paragraph, and the limitations of
- the checks (see the end of `references/interpretation.md`).
- Finish by telling the user, in a few lines: the overall verdict per key coefficient, the
- one or two changes you recommend, and the paths of the report and tables.
- ## When the request is narrower
- - "Just run the tests": steps 1–4, plus the diagnostics table.
- - "Is my result robust?": steps 1, 2, 5, a short report.
- - Time series or cross section: `ols_diagnostics.py` covers steps 3 and 5 together.
- - Models the scripts do not cover (IV/2SLS, GMM, nonlinear, VAR, survival): say so, run
- what applies (`inspect_data.py`, residual checks via a formula approximation if
- meaningful), and list the specific tests the user should run instead
- (`references/interpretation.md`, "Not covered").
README.md · README · 63 lines
- # econometric-diagnostics
- A Claude Code skill that reviews an estimated econometric
- model the way a careful referee would: it replicates the baseline, runs the specification
- and diagnostic tests that fit the data structure, decides the appropriate estimator and
- standard errors, stress-tests the key coefficients with a one-change-at-a-time robustness
- battery, and writes LaTeX tables plus an interpreted report.
- The Python scripts do the computing; the skill instructions (`SKILL.md`) and the reference
- files tell Claude how to read the results — including when a test is invalid in a given
- setting (classic Hausman under clustering, Pesaran CD after time effects, first-generation
- unit-root tests under cross-sectional dependence).
- ## What it covers
- | Data | Diagnostics | Robustness |
- |---|---|---|
- | **Panel** | F tests for entity and time effects, Breusch-Pagan LM, Hausman, Mundlak (cluster-robust), Wooldridge AR(1), modified Wald, Pesaran CD, Fisher-ADF unit roots, within VIF, outliers | SEs: iid, robust, clustered (entity, time, two-way), Driscoll-Kraay · Estimators: pooled, RE, FE, two-way FE, first differences, between, dynamic FE · Sample: winsorizing, trimming, balanced sub-panel, early/late split, leave-one-entity-out jackknife |
- | **Time series** | ADF + KPSS integration order, Engle-Granger, Breusch-Godfrey, Ljung-Box, Breusch-Pagan, ARCH-LM, Jarque-Bera, RESET, CUSUM | SEs: iid, HC, HAC · Huber, LAD, first differences, lagged y · Cook's D, winsorizing, sample halves |
- | **Cross section** | Breusch-Pagan, White, RESET, Jarque-Bera, VIF, Cook's distance | SEs: iid, HC1, HC3, clustered · Huber, LAD · Cook's D, winsorizing |
- Each coefficient gets a verdict (`ROBUST`, `MOSTLY ROBUST`, `FRAGILE`), and sub-sample
- differences are reported separately as **heterogeneity**, not as fragility.
- ## Install
- ```bash
- git clone https://github.com/<user>/econometric-diagnostics ~/.claude/skills/econometric-diagnostics
- pip install -r ~/.claude/skills/econometric-diagnostics/requirements.txt
- ```
- Then, in Claude Code, inside your research project:
- > Check the robustness of the models in `models/baseline.py`.
- ## Use the scripts directly
- ```bash
- cd examples
- python make_example_data.py
- python ../scripts/inspect_data.py config_example.json
- python ../scripts/panel_diagnostics.py config_example.json
- python ../scripts/robustness.py config_example.json
- python ../scripts/to_latex.py config_example.json --lang en
- ```
- The config format is documented in [`references/config_schema.md`](references/config_schema.md).
- ## Layout
- ```
- SKILL.md workflow and ground rules Claude follows
- scripts/ inspect_data, panel_diagnostics, robustness, ols_diagnostics, to_latex
- references/ decision tree, interpretation of each test, config schema
- templates/ report template
- examples/ synthetic panel with a known data-generating process
- ```
- ## Limitations
- Not covered: IV/2SLS and GMM diagnostics, second-generation panel unit roots (CIPS),
- panel cointegration, wild cluster bootstrap, nonlinear models. The skill says so and
- recommends the right tests when a model needs them.
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.