[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F1PZQ0YQBXKECZJP2R4YP7":3,"skill-same:01M7F1PZQ0YQBXKECZJP2R4YP7":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":34,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M7F1PZQ0YQBXKECZJP2R4YP7","stata-regression",null,"> Generates rigorous, reproducible Stata regression workflows that follow World Bank DIME Analytics conventions (`ietoolkit`, `iefolder`, master do-files, `ieboilstart`, dynamic absolute paths, `iebaltab`, `ieddtab`, `esttab`). Defaults to modern estimators (`reghdfe`, `ivreg2`\u002F`ivreghdfe`, `csdid`,","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: stata-regression\ndescription: \"> Generates rigorous, reproducible Stata regression workflows that follow World Bank DIME Analytics conventions (`ietoolkit`, `iefolder`, master do-files, `ieboilstart`, dynamic absolute paths, `iebaltab`, `ieddtab`, `esttab`). Defaults to modern estimators (`reghdfe`, `ivreg2`\u002F`ivreghdfe`, `csdid`,\"\ncategory: economics\nversion: 1.0.0\ndisable-model-invocation: false\nrisk: low\nsource: \"https:\u002F\u002Fgithub.com\u002FJonasWeinert\u002FEconAgentSkills\"\nsource_repository: \"JonasWeinert\u002FEconAgentSkills\"\nsource_path: \"_skills\u002Fanalysis\u002Fstata-regression\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n# Stata Regression\n\nGenerate rigorous, reproducible Stata code that follows DIME Analytics impact-evaluation conventions and uses modern econometric estimators. The default style is `ietoolkit` + `reghdfe` + `esttab`, with heterogeneity-robust DiD and weak-IV-robust inference baked in.\n\n## Operating Principles\n\n1. **Reproducibility before convenience.** Every script starts with `ieboilstart`, sets a seed, declares dynamic absolute paths via globals, and writes outputs to a `Results\u002F` folder. Never `cd`, never use relative paths, never commit `.dta` files containing PII.\n2. **Modern estimators by default.** Plain `xi: reg y treat##post` under staggered timing is biased; use `csdid`, `eventstudyinteract`, `did_imputation`, or `jwdid`. For weak instruments, use `ivreg2 ... weakid` and `weakivtest`. With few clusters, use `boottest`.\n3. **`ietoolkit` is the house standard.** Use `iebaltab` for balance, `ieddtab` for simple two-period DiD, `iefolder` for project setup, `iegraph` for regression-result figures, and `iedropone` for safe drops.\n4. **One do-file, one purpose.** Master do-file installs packages and routes to sub-do-files for cleaning, construction, analysis, and output. Each script must run end-to-end from a clean Stata session.\n5. **Tables are produced, never copy-pasted.** All tables go through `esttab` to `.tex`, `.csv`, or `.rtf` — no manual editing.\n\n## Decision Policy\n\nThis skill follows the repo-wide [Agent Policy](..\u002F..\u002FAGENT_POLICY.md).\n\n**ASK before proceeding** (blocking):\n\n1. Estimand and identification strategy.\n2. Treatment timing (uniform vs staggered) — drives `csdid` \u002F `eventstudyinteract` \u002F `did_imputation` vs plain TWFE.\n3. Cluster level for inference (matches assignment level by default).\n4. DataWork folder layout: which globals to use, where do tables\u002Ffigures land.\n\n**DEFAULT + flag** (use this default; tell the user how to override):\n\n- `reghdfe` over `xtreg` \u002F `areg` for high-dim FE.\n- `csdid` (Callaway-Sant'Anna) as preferred staggered-DiD estimator; report TWFE as benchmark in `tab_did_estimators`.\n- `ivreg2` + `weakivtest` with cluster-robust SEs for IV; switch to `condivreg` when effective F \u003C 100.\n- `boottest` wild cluster bootstrap when G \u003C 30 or treatment is concentrated in a few clusters.\n- `esttab` for tables; `coefplot` for figures; `iebaltab` for balance.\n- Outputs to `${tabs}\u002F` (.tex) and `${figs}\u002F` (.pdf), declared by master do-file globals.\n\n**DOCUMENT and proceed** (write into the decisions log):\n\n- Specific estimator within an approved family.\n- The cluster level and the number of clusters G.\n- Any sample restriction beyond what the user named.\n- Choice of bandwidth in RDD and sensitivity range.\n\n`PROCEED` items: `ieboilstart`, dynamic absolute paths via globals, `isid`, `iedropone`, `assert`, `set seed`, never `cd`, never copy-paste numbers from the Results window.\n\n## Pre-flight Checklist\n\nBefore writing code, confirm with the user — and write the answers as a header comment block:\n\n- **Estimand.** ATT, LATE, ITT, sharp\u002Ffuzzy RD effect, descriptive, or balance check?\n- **Unit of observation and panel keys.** Assert with `isid` (e.g. `isid hhid year`).\n- **Treatment timing.** Single shock, simultaneous, staggered, or reversible?\n- **Identifying variation.** Which comparison drives the coefficient?\n- **Clustering level.** Where is treatment assigned, or where does within-group correlation live?\n- **Sample.** Document each filter and report the resulting N.\n- **Output target.** Working paper, slides, journal submission, or internal report.\n\n## DIME Project Layout\n\nEvery analysis script assumes a `DataWork\u002F` folder created by `iefolder`:\n\n```\nProjectABC\u002F\n├── DataWork\u002F\n│   ├── MasterDoFile.do            # globals, packages, routes to sub-master files\n│   ├── Baseline\u002F\n│   │   ├── DataSets\u002F\n│   │   │   ├── Raw\u002F\n│   │   │   ├── Intermediate\u002F\n│   │   │   └── Final\u002F\n│   │   ├── Dofiles\u002F\n│   │   │   ├── Cleaning\u002F\n│   │   │   ├── Construction\u002F\n│   │   │   └── Analysis\u002F\n│   │   ├── Output\u002F\n│   │   │   ├── Tables\u002F\n│   │   │   └── Figures\u002F\n│   │   └── Documentation\u002F\n│   └── Endline\u002F\n└── README.md\n```\n\nGlobals are user-specific and defined only in the master do-file:\n\n```stata\n* Master do-file globals\nif c(username) == \"jonas\"      global root \"\u002FUsers\u002Fjonas\u002FDropbox\u002FProjectABC\"\nif c(username) == \"coauthor\"   global root \"C:\u002FUsers\u002Fcoauthor\u002FDropbox\u002FProjectABC\"\n\nglobal dataWork  \"${root}\u002FDataWork\"\nglobal baseline  \"${dataWork}\u002FBaseline\"\nglobal results   \"${baseline}\u002FOutput\"\n```\n\n## Estimator Decision Tree\n\n### Difference-in-Differences\n\n```\nTwo periods, two groups, no staggered adoption\n└── ieddtab y, t(time) treatment(treated)  \u002F\u002F DIME-style two-period DD\n    or:    reghdfe y treat_post, absorb(unit time) vce(cluster unit)\n\nStaggered adoption (the realistic case)\n└── Do NOT use plain TWFE. Choose one of:\n    ├── csdid           → Callaway & Sant'Anna (2021)\n    ├── eventstudyinteract → Sun & Abraham (2021)\n    ├── did_imputation  → Borusyak, Jaravel & Spiess (2024)\n    ├── did_multiplegt_dyn → de Chaisemartin & D'Haultfoeuille\n    └── jwdid           → Wooldridge (2021), TWFE re-derivation\n\nContinuous or non-binary treatment\n└── did_multiplegt_dyn (de Chaisemartin & D'Haultfoeuille)\n```\n\n### Instrumental Variables\n\n```\nAlways estimate and report the first stage explicitly.\n\nFor 2SLS with diagnostics:\n  ivreg2 y x_exog (endog = z), cluster(cluster_var) first\n\nWeak-IV diagnostics:\n  - ivreg2 reports Kleibergen-Paap rk Wald F\n  - weakivtest after ivreg2 → Olea-Pflueger effective F\n  - condivreg or rivtest → Anderson-Rubin \u002F CLR confidence sets\n\nEffective F (Olea-Pflueger):\n  - F >= 100 → conventional t is fine\n  - 10 \u003C= F \u003C 100 → use AR or tF-adjusted CI\n  - F \u003C 10  → instrument is weak; do not interpret 2SLS causally\n\nPanel IV with high-dim FE:\n  ivreghdfe y x_exog (endog = z), absorb(unit time) cluster(cluster_var) first\n```\n\n### Regression Discontinuity\n\n```\nSharp RDD:\n  rdrobust y x, c(0)                            \u002F\u002F Calonico-Cattaneo-Titiunik\n  rdplot   y x, c(0) binselect(esmv)\n  rddensity x, c(0)                              \u002F\u002F density manipulation test\n\nFuzzy RDD:\n  rdrobust y x, c(0) fuzzy(treatment)\n\nBandwidth sensitivity:\n  Loop over h_opt\u002F2, h_opt, 2*h_opt and report the table.\n```\n\n### Inference\n\n```\nNumber of clusters G:\n  G >= 50      → vce(cluster cl) is fine\n  30 \u003C= G \u003C 50 → reg2hdfe or boottest with t-statistic correction\n  G \u003C 30       → wild cluster bootstrap via boottest, type(rademacher)\n\nMulti-way clustering:\n  Use vce2way (or `, vce(cluster cl1 cl2)` in some commands).\n  Only when there is real correlation along both dimensions.\n\nFew-cluster small-sample fix in reghdfe:\n  reghdfe y x, absorb(unit time) vce(cluster unit, suite(boot))\n```\n\n## Output Skeleton\n\nEvery analysis do-file should follow this structure:\n\n```stata\n*-------------------------------------------------------------*\n* Project   : ProjectABC\n* Purpose   : Main DiD specification on outcome Y\n* Author    : First Last (email)\n* Created   : 2026-05-05\n* Inputs    : ${baseline}\u002FDataSets\u002FFinal\u002Fanalysis.dta\n* Outputs   : ${results}\u002FTables\u002Ftable_did_main.tex\n*             ${results}\u002FFigures\u002Fevent_study.pdf\n* Estimand  : ATT of program on outcome Y\n* Cluster   : at the unit level (treatment assignment)\n*-------------------------------------------------------------*\n\n* 0. Settings\nieboilstart, version(17.0)\n`r(version)'\n\n* 1. Load and assert structure\nuse \"${baseline}\u002FDataSets\u002FFinal\u002Fanalysis.dta\", clear\nisid unit_id year\n\n* 2. Sample construction (log every drop)\niedropone if missing(outcome), error  \u002F\u002F hard-fail if pattern is unexpected\n\n* 3. Descriptives + balance\niebaltab age gender baseline_y, grpvar(treated) \u002F\u002F\u002F\n    save(\"${results}\u002FTables\u002Fbalance.xlsx\") replace\n\n* 4. Main specification\neststo clear\nreghdfe outcome treat_post, absorb(unit_id year) vce(cluster unit_id)\neststo main\n\n* 5. Robustness ladder\nreghdfe outcome treat_post, absorb(unit_id year) vce(cluster unit_id year)\neststo twoway\n\nreghdfe outcome treat_post controls, absorb(unit_id year) vce(cluster unit_id)\neststo controls\n\n* 6. Export\nesttab main twoway controls using \"${results}\u002FTables\u002Ftable_did_main.tex\", \u002F\u002F\u002F\n    replace booktabs label se \u002F\u002F\u002F\n    stats(N r2_within, fmt(%9.0fc %9.3f) labels(\"Observations\" \"Within R2\")) \u002F\u002F\u002F\n    star(* 0.10 ** 0.05 *** 0.01) \u002F\u002F\u002F\n    notes(\"Cluster-robust SEs in parentheses.\")\n```\n\n## Common Pitfalls\n\n- Plain `xi: reg y i.treat##i.post` with staggered timing — biased; use `csdid` or `eventstudyinteract`.\n- Conditioning on first-stage F > 10 — biased; report Olea-Pflueger F and AR.\n- `vce(cluster cl)` with very few clusters — undercoverage; use `boottest`.\n- Hardcoded paths and `cd` — break collaboration; use globals from the master do-file.\n- Copy-pasting tables into Word — kills reproducibility; always go through `esttab`.\n- Quietly dropping observations — every drop should be logged or use `iedropone`.\n- Saving `.dta` with PII or running scripts on raw confidential data — see DIME PII guidance.\n- `xtreg, fe` for high-dim FE — slow and limited; use `reghdfe`.\n\n## Additional Resources\n\n- `reference.md` — extended code patterns for each estimator family.\n- `examples\u002F` — runnable do-files:\n  - `examples\u002Fmaster.do` — DIME-style master do-file\n  - `examples\u002Freghdfe_baseline.do` — reghdfe + esttab workflow\n  - `examples\u002Fiebaltab_balance.do` — balance tables with `iebaltab`\n  - `examples\u002Fcsdid_staggered.do` — Callaway-Sant'Anna in Stata\n  - `examples\u002Feventstudyinteract_sa.do` — Sun-Abraham event study\n  - `examples\u002Fdid_imputation_bjs.do` — BJS imputation estimator\n  - `examples\u002Fivreg2_weak.do` — IV with `weakivtest`\n  - `examples\u002Frdrobust_sharp.do` — sharp RDD with `rdrobust`\n  - `examples\u002Fboottest_few_clusters.do` — wild cluster bootstrap\n\n## Requirements\n\n- Stata >= 16 (Stata 17+ recommended for `frames` and faster matrix ops).\n- DIME packages: `ietoolkit`, `iefieldkit`.\n- Estimation: `reghdfe`, `ivreg2`, `ivreghdfe`, `weakivtest`.\n- Modern DiD: `csdid`, `did_imputation`, `did_multiplegt_dyn`, `eventstudyinteract`, `jwdid`.\n- RDD: `rdrobust`, `rddensity`.\n- Inference: `boottest`, `vce2way`.\n- Tables and figures: `estout` (provides `esttab`), `coefplot`, `outreg2`.\n\n```stata\n* Run once, or include with `, replace` in the master do-file.\nssc install ietoolkit,        replace\nssc install iefieldkit,       replace\nssc install reghdfe,          replace\nssc install ftools,           replace        \u002F\u002F dependency for reghdfe\nssc install ivreg2,           replace\nssc install ivreghdfe,        replace\nssc install ranktest,         replace        \u002F\u002F dependency for ivreg2\nssc install weakivtest,       replace\nssc install csdid,            replace\nssc install drdid,            replace        \u002F\u002F dependency for csdid\nssc install did_imputation,   replace\nssc install did_multiplegt_dyn, replace\nssc install eventstudyinteract, replace\nssc install jwdid,            replace\nssc install rdrobust,         replace\nssc install rddensity,        replace\nssc install boottest,         replace\nssc install estout,           replace\nssc install coefplot,         replace\nssc install outreg2,          replace\n```\n\n## References\n\n### DIME Conventions\n\n- DIME Analytics, [Stata Coding Practices](https:\u002F\u002Fdimewiki.worldbank.org\u002FStata_Coding_Practices)\n- DIME Analytics, [Master Do-files](https:\u002F\u002Fdimewiki.worldbank.org\u002FMaster_Do-files)\n- DIME Analytics, [ietoolkit](https:\u002F\u002Fdimewiki.worldbank.org\u002Fietoolkit)\n- DIME Analytics, [Reproducible Research](https:\u002F\u002Fdimewiki.worldbank.org\u002FReproducible_Research)\n- DIME Analytics, [Data Analysis](https:\u002F\u002Fdimewiki.worldbank.org\u002FData_Analysis)\n- DIME Analytics, [Difference-in-Differences](https:\u002F\u002Fdimewiki.worldbank.org\u002FDifference-in-Differences)\n- *Development Research in Practice* (DIME Analytics handbook).\n\n### Methods\n\n- Goodman-Bacon (2021). *DiD with Variation in Treatment Timing*. JoE.\n- Callaway & Sant'Anna (2021). *DiD with Multiple Time Periods*. JoE.\n- Sun & Abraham (2021). *Estimating Dynamic Treatment Effects in Event Studies*. JoE.\n- Borusyak, Jaravel & Spiess (2024). *Revisiting Event Study Designs*. ReStud.\n- Olea & Pflueger (2013). *A Robust Test for Weak Instruments*. JBES.\n- Lee, McCrary, Moreira & Porter (2022). *Valid t-ratio Inference for IV*. AER.\n- Calonico, Cattaneo & Titiunik (2014). *Robust Nonparametric CIs for RDD*. Econometrica.\n- MacKinnon & Webb (2018). *Wild Bootstrap for Few (Treated) Clusters*. EJ.\n","# Stata Regression\n\nGenerate rigorous, reproducible Stata code that follows DIME Analytics impact-evaluation conventions and uses modern econometric estimators. The default style is `ietoolkit` + `reghdfe` + `esttab`, with heterogeneity-robust DiD and weak-IV-robust inference baked in.\n\n## Operating Principles\n\n1. **Reproducibility before convenience.** Every script starts with `ieboilstart`, sets a seed, declares dynamic absolute paths via globals, and writes outputs to a `Results\u002F` folder. Never `cd`, never use relative paths, never commit `.dta` files containing PII.\n2. **Modern estimators by default.** Plain `xi: reg y treat##post` under staggered timing is biased; use `csdid`, `eventstudyinteract`, `did_imputation`, or `jwdid`. For weak instruments, use `ivreg2 ... weakid` and `weakivtest`. With few clusters, use `boottest`.\n3. **`ietoolkit` is the house standard.** Use `iebaltab` for balance, `ieddtab` for simple two-period DiD, `iefolder` for project setup, `iegraph` for regression-result figures, and `iedropone` for safe drops.\n4. **One do-file, one purpose.** Master do-file installs packages and routes to sub-do-files for cleaning, construction, analysis, and output. Each script must run end-to-end from a clean Stata session.\n5. **Tables are produced, never copy-pasted.** All tables go through `esttab` to `.tex`, `.csv`, or `.rtf` — no manual editing.\n\n## Decision Policy\n\nThis skill follows the repo-wide [Agent Policy](..\u002F..\u002FAGENT_POLICY.md).\n\n**ASK before proceeding** (blocking):\n\n1. Estimand and identification strategy.\n2. Treatment timing (uniform vs staggered) — drives `csdid` \u002F `eventstudyinteract` \u002F `did_imputation` vs plain TWFE.\n3. Cluster level for inference (matches assignment level by default).\n4. DataWork folder layout: which globals to use, where do tables\u002Ffigures land.\n\n**DEFAULT + flag** (use this default; tell the user how to override):\n\n- `reghdfe` over `xtreg` \u002F `areg` for high-dim FE.\n- `csdid` (Callaway-Sant'Anna) as preferred staggered-DiD estimator; report TWFE as benchmark in `tab_did_estimators`.\n- `ivreg2` + `weakivtest` with cluster-robust SEs for IV; switch to `condivreg` when effective F \u003C 100.\n- `boottest` wild cluster bootstrap when G \u003C 30 or treatment is concentrated in a few clusters.\n- `esttab` for tables; `coefplot` for figures; `iebaltab` for balance.\n- Outputs to `${tabs}\u002F` (.tex) and `${figs}\u002F` (.pdf), declared by master do-file globals.\n\n**DOCUMENT and proceed** (write into the decisions log):\n\n- Specific estimator within an approved family.\n- The cluster level and the number of clusters G.\n- Any sample restriction beyond what the user named.\n- Choice of bandwidth in RDD and sensitivity range.\n\n`PROCEED` items: `ieboilstart`, dynamic absolute paths via globals, `isid`, `iedropone`, `assert`, `set seed`, never `cd`, never copy-paste numbers from the Results window.\n\n## Pre-flight Checklist\n\nBefore writing code, confirm with the user — and write the answers as a header comment block:\n\n- **Estimand.** ATT, LATE, ITT, sharp\u002Ffuzzy RD effect, descriptive, or balance check?\n- **Unit of observation and panel keys.** Assert with `isid` (e.g. `isid hhid year`).\n- **Treatment timing.** Single shock, simultaneous, staggered, or reversible?\n- **Identifying variation.** Which comparison drives the coefficient?\n- **Clustering level.** Where is treatment assigned, or where does within-group correlation live?\n- **Sample.** Document each filter and report the resulting N.\n- **Output target.** Working paper, slides, journal submission, or internal report.\n\n## DIME Project Layout\n\nEvery analysis script assumes a `DataWork\u002F` folder created by `iefolder`:\n\n```\nProjectABC\u002F\n├── DataWork\u002F\n│   ├── MasterDoFile.do            # globals, packages, routes to sub-master files\n│   ├── Baseline\u002F\n│   │   ├── DataSets\u002F\n│   │   │   ├── Raw\u002F\n│   │   │   ├── Intermediate\u002F\n│   │   │   └── Final\u002F\n│   │   ├── Dofiles\u002F\n│   │   │   ├── Cleaning\u002F\n│   │   │   ├── Construction\u002F\n│   │   │   └── Analysis\u002F\n│   │   ├── Output\u002F\n│   │   │   ├── Tables\u002F\n│   │   │   └── Figures\u002F\n│   │   └── Documentation\u002F\n│   └── Endline\u002F\n└── README.md\n```\n\nGlobals are user-specific and defined only in the master do-file:\n\n```stata\n* Master do-file globals\nif c(username) == \"jonas\"      global root \"\u002FUsers\u002Fjonas\u002FDropbox\u002FProjectABC\"\nif c(username) == \"coauthor\"   global root \"C:\u002FUsers\u002Fcoauthor\u002FDropbox\u002FProjectABC\"\n\nglobal dataWork  \"${root}\u002FDataWork\"\nglobal baseline  \"${dataWork}\u002FBaseline\"\nglobal results   \"${baseline}\u002FOutput\"\n```\n\n## Estimator Decision Tree\n\n### Difference-in-Differences\n\n```\nTwo periods, two groups, no staggered adoption\n└── ieddtab y, t(time) treatment(treated)  \u002F\u002F DIME-style two-period DD\n    or:    reghdfe y treat_post, absorb(unit time) vce(cluster unit)\n\nStaggered adoption (the realistic case)\n└── Do NOT use plain TWFE. Choose one of:\n    ├── csdid           → Callaway & Sant'Anna (2021)\n    ├── eventstudyinteract → Sun & Abraham (2021)\n    ├── did_imputation  → Borusyak, Jaravel & Spiess (2024)\n    ├── did_multiplegt_dyn → de Chaisemartin & D'Haultfoeuille\n    └── jwdid           → Wooldridge (2021), TWFE re-derivation\n\nContinuous or non-binary treatment\n└── did_multiplegt_dyn (de Chaisemartin & D'Haultfoeuille)\n```\n\n### Instrumental Variables\n\n```\nAlways estimate and report the first stage explicitly.\n\nFor 2SLS with diagnostics:\n  ivreg2 y x_exog (endog = z), cluster(cluster_var) first\n\nWeak-IV diagnostics:\n  - ivreg2 reports Kleibergen-Paap rk Wald F\n  - weakivtest after ivreg2 → Olea-Pflueger effective F\n  - condivreg or rivtest → Anderson-Rubin \u002F CLR confidence sets\n\nEffective F (Olea-Pflueger):\n  - F >= 100 → conventional t is fine\n  - 10 \u003C= F \u003C 100 → use AR or tF-adjusted CI\n  - F \u003C 10  → instrument is weak; do not interpret 2SLS causally\n\nPanel IV with high-dim FE:\n  ivreghdfe y x_exog (endog = z), absorb(unit time) cluster(cluster_var) first\n```\n\n### Regression Discontinuity\n\n```\nSharp RDD:\n  rdrobust y x, c(0)                            \u002F\u002F Calonico-Cattaneo-Titiunik\n  rdplot   y x, c(0) binselect(esmv)\n  rddensity x, c(0)                              \u002F\u002F density manipulation test\n\nFuzzy RDD:\n  rdrobust y x, c(0) fuzzy(treatment)\n\nBandwidth sensitivity:\n  Loop over h_opt\u002F2, h_opt, 2*h_opt and report the table.\n```\n\n### Inference\n\n```\nNumber of clusters G:\n  G >= 50      → vce(cluster cl) is fine\n  30 \u003C= G \u003C 50 → reg2hdfe or boottest with t-statistic correction\n  G \u003C 30       → wild cluster bootstrap via boottest, type(rademacher)\n\nMulti-way clustering:\n  Use vce2way (or `, vce(cluster cl1 cl2)` in some commands).\n  Only when there is real correlation along both dimensions.\n\nFew-cluster small-sample fix in reghdfe:\n  reghdfe y x, absorb(unit time) vce(cluster unit, suite(boot))\n```\n\n## Output Skeleton\n\nEvery analysis do-file should follow this structure:\n\n```stata\n*-------------------------------------------------------------*\n* Project   : ProjectABC\n* Purpose   : Main DiD specification on outcome Y\n* Author    : First Last (email)\n* Created   : 2026-05-05\n* Inputs    : ${baseline}\u002FDataSets\u002FFinal\u002Fanalysis.dta\n* Outputs   : ${results}\u002FTables\u002Ftable_did_main.tex\n*             ${results}\u002FFigures\u002Fevent_study.pdf\n* Estimand  : ATT of program on outcome Y\n* Cluster   : at the unit level (treatment assignment)\n*-------------------------------------------------------------*\n\n* 0. Settings\nieboilstart, version(17.0)\n`r(version)'\n\n* 1. Load and assert structure\nuse \"${baseline}\u002FDataSets\u002FFinal\u002Fanalysis.dta\", clear\nisid unit_id year\n\n* 2. Sample construction (log every drop)\niedropone if missing(outcome), error  \u002F\u002F hard-fail if pattern is unexpected\n\n* 3. Descriptives + balance\niebaltab age gender baseline_y, grpvar(treated) \u002F\u002F\u002F\n    save(\"${results}\u002FTables\u002Fbalance.xlsx\") replace\n\n* 4. Main specification\neststo clear\nreghdfe outcome treat_post, absorb(unit_id year) vce(cluster unit_id)\neststo main\n\n* 5. Robustness ladder\nreghdfe outcome treat_post, absorb(unit_id year) vce(cluster unit_id year)\neststo twoway\n\nreghdfe outcome treat_post controls, absorb(unit_id year) vce(cluster unit_id)\neststo controls\n\n* 6. Export\nesttab main twoway controls using \"${results}\u002FTables\u002Ftable_did_main.tex\", \u002F\u002F\u002F\n    replace booktabs label se \u002F\u002F\u002F\n    stats(N r2_within, fmt(%9.0fc %9.3f) labels(\"Observations\" \"Within R2\")) \u002F\u002F\u002F\n    star(* 0.10 ** 0.05 *** 0.01) \u002F\u002F\u002F\n    notes(\"Cluster-robust SEs in parentheses.\")\n```\n\n## Common Pitfalls\n\n- Plain `xi: reg y i.treat##i.post` with staggered timing — biased; use `csdid` or `eventstudyinteract`.\n- Conditioning on first-stage F > 10 — biased; report Olea-Pflueger F and AR.\n- `vce(cluster cl)` with very few clusters — undercoverage; use `boottest`.\n- Hardcoded paths and `cd` — break collaboration; use globals from the master do-file.\n- Copy-pasting tables into Word — kills reproducibility; always go through `esttab`.\n- Quietly dropping observations — every drop should be logged or use `iedropone`.\n- Saving `.dta` with PII or running scripts on raw confidential data — see DIME PII guidance.\n- `xtreg, fe` for high-dim FE — slow and limited; use `reghdfe`.\n\n## Additional Resources\n\n- `reference.md` — extended code patterns for each estimator family.\n- `examples\u002F` — runnable do-files:\n  - `examples\u002Fmaster.do` — DIME-style master do-file\n  - `examples\u002Freghdfe_baseline.do` — reghdfe + esttab workflow\n  - `examples\u002Fiebaltab_balance.do` — balance tables with `iebaltab`\n  - `examples\u002Fcsdid_staggered.do` — Callaway-Sant'Anna in Stata\n  - `examples\u002Feventstudyinteract_sa.do` — Sun-Abraham event study\n  - `examples\u002Fdid_imputation_bjs.do` — BJS imputation estimator\n  - `examples\u002Fivreg2_weak.do` — IV with `weakivtest`\n  - `examples\u002Frdrobust_sharp.do` — sharp RDD with `rdrobust`\n  - `examples\u002Fboottest_few_clusters.do` — wild cluster bootstrap\n\n## Requirements\n\n- Stata >= 16 (Stata 17+ recommended for `frames` and faster matrix ops).\n- DIME packages: `ietoolkit`, `iefieldkit`.\n- Estimation: `reghdfe`, `ivreg2`, `ivreghdfe`, `weakivtest`.\n- Modern DiD: `csdid`, `did_imputation`, `did_multiplegt_dyn`, `eventstudyinteract`, `jwdid`.\n- RDD: `rdrobust`, `rddensity`.\n- Inference: `boottest`, `vce2way`.\n- Tables and figures: `estout` (provides `esttab`), `coefplot`, `outreg2`.\n\n```stata\n* Run once, or include with `, replace` in the master do-file.\nssc install ietoolkit,        replace\nssc install iefieldkit,       replace\nssc install reghdfe,          replace\nssc install ftools,           replace        \u002F\u002F dependency for reghdfe\nssc install ivreg2,           replace\nssc install ivreghdfe,        replace\nssc install ranktest,         replace        \u002F\u002F dependency for ivreg2\nssc install weakivtest,       replace\nssc install csdid,            replace\nssc install drdid,            replace        \u002F\u002F dependency for csdid\nssc install did_imputation,   replace\nssc install did_multiplegt_dyn, replace\nssc install eventstudyinteract, replace\nssc install jwdid,            replace\nssc install rdrobust,         replace\nssc install rddensity,        replace\nssc install boottest,         replace\nssc install estout,           replace\nssc install coefplot,         replace\nssc install outreg2,          replace\n```\n\n## References\n\n### DIME Conventions\n\n- DIME Analytics, [Stata Coding Practices](https:\u002F\u002Fdimewiki.worldbank.org\u002FStata_Coding_Practices)\n- DIME Analytics, [Master Do-files](https:\u002F\u002Fdimewiki.worldbank.org\u002FMaster_Do-files)\n- DIME Analytics, [ietoolkit](https:\u002F\u002Fdimewiki.worldbank.org\u002Fietoolkit)\n- DIME Analytics, [Reproducible Research](https:\u002F\u002Fdimewiki.worldbank.org\u002FReproducible_Research)\n- DIME Analytics, [Data Analysis](https:\u002F\u002Fdimewiki.worldbank.org\u002FData_Analysis)\n- DIME Analytics, [Difference-in-Differences](https:\u002F\u002Fdimewiki.worldbank.org\u002FDifference-in-Differences)\n- *Development Research in Practice* (DIME Analytics handbook).\n\n### Methods\n\n- Goodman-Bacon (2021). *DiD with Variation in Treatment Timing*. JoE.\n- Callaway & Sant'Anna (2021). *DiD with Multiple Time Periods*. JoE.\n- Sun & Abraham (2021). *Estimating Dynamic Treatment Effects in Event Studies*. JoE.\n- Borusyak, Jaravel & Spiess (2024). *Revisiting Event Study Designs*. ReStud.\n- Olea & Pflueger (2013). *A Robust Test for Weak Instruments*. JBES.\n- Lee, McCrary, Moreira & Porter (2022). *Valid t-ratio Inference for IV*. AER.\n- Calonico, Cattaneo & Titiunik (2014). *Robust Nonparametric CIs for RDD*. Econometrica.\n- MacKinnon & Webb (2018). *Wild Bootstrap for Few (Treated) Clusters*. EJ.\n",{"name":5,"risk":24,"source":25,"license":15,"version":26,"category":27,"description":7,"imported_at":28,"source_path":29,"source_repository":30,"disable-model-invocation":20},"low","https:\u002F\u002Fgithub.com\u002FJonasWeinert\u002FEconAgentSkills","1.0.0","economics","2026-09-20","_skills\u002Fanalysis\u002Fstata-regression\u002FSKILL.md","JonasWeinert\u002FEconAgentSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Feconomics\u002Fstata-regression","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill stata-regression",{"tool":43,"command":44},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill stata-regression",{"tool":46,"command":47},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill stata-regression","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002FSKILL.md",true,[51,57,61,65,69,73,77,81,85,89],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"examples\u002Fboottest_few_clusters.do","OTHER","其他",1223,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fboottest_few_clusters.do",{"path":58,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":59,"sourceHtmlUrl":60},"examples\u002Fcsdid_staggered.do",1782,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fcsdid_staggered.do",{"path":62,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":63,"sourceHtmlUrl":64},"examples\u002Fdid_imputation_bjs.do",1138,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fdid_imputation_bjs.do",{"path":66,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":67,"sourceHtmlUrl":68},"examples\u002Feventstudyinteract_sa.do",1362,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Feventstudyinteract_sa.do",{"path":70,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":71,"sourceHtmlUrl":72},"examples\u002Fiebaltab_balance.do",1175,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fiebaltab_balance.do",{"path":74,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":75,"sourceHtmlUrl":76},"examples\u002Fivreg2_weak.do",1865,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fivreg2_weak.do",{"path":78,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":79,"sourceHtmlUrl":80},"examples\u002Fmaster.do",2762,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Fmaster.do",{"path":82,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":83,"sourceHtmlUrl":84},"examples\u002Frdrobust_sharp.do",2053,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Frdrobust_sharp.do",{"path":86,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":87,"sourceHtmlUrl":88},"examples\u002Freghdfe_baseline.do",1737,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Fexamples\u002Freghdfe_baseline.do",{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"reference.md","REFERENCE","参考文档",9169,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Feconomics\u002Fstata-regression\u002Freference.md",[96,103,110,117,124,131],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":19},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":19},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":19},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":19},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]