- Home
- Skills
- Meleantonio
- Awesome Econ Ai Stuff
- Python Panel Data
python-panel-data_skill
- HTML
156
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill meleantonio/awesome-econ-ai-stuff --skill python-panel-data- index.md3.1 KB
- SKILL.md3.1 KB
Overview
This skill provides practical tools for panel data analysis in Python using pandas, linearmodels, and statsmodels. It guides users through indexing panels, fitting fixed or random effects, clustering standard errors, and exporting readable regression tables. The focus is on producing reproducible code and clear interpretation for applied economic research.
How this skill works
After clarifying panel identifiers, outcomes, regressors, and clustering choices, the skill generates Python code that loads and cleans data, sets a MultiIndex for panel structure, and fits models with PanelOLS or RandomEffects. It configures covariances for clustering or heteroskedasticity, formats results for display or LaTeX, and outputs interpretation guidance and recommended robustness checks.
When to use it
- Estimating entity, time, or two-way fixed effects models
- Running difference-in-differences (DiD) on panel datasets
- Testing random effects versus fixed effects
- Clustering standard errors at the appropriate group level
- Exporting regression tables and LaTeX-ready output
Best practices
- Verify and document panel identifiers and whether the panel is balanced or unbalanced
- Cluster standard errors at the level of policy assignment or groupwise correlation
- Check and handle missing data before setting the panel index
- Report model specification, identification assumptions (e.g. strict exogeneity, parallel trends), and key diagnostics
- Run robustness checks: alternative clustering, placebo tests, and different control sets
Example use cases
- Two-way fixed effects for firm-year data estimating policy impacts
- State-level DiD with state and year fixed effects and clustered SEs
- Random effects specification for long panels where between variation matters
- Exporting regression tables to LaTeX for inclusion in academic papers
- Quick diagnostic workflow: set index, fit PanelOLS, compare clustered vs robust SEs
FAQ
I use pandas for data management, linearmodels for panel estimators (PanelOLS, RandomEffects), and statsmodels for supplemental tests and diagnostics.
How should I choose clustering level?
Cluster at the level where residuals are likely correlated (policy adoption, firm, or region). When in doubt, report multiple clustering choices as robustness checks.