@wentorai/research-plugins 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/curated/analysis/README.md +64 -0
- package/curated/domains/README.md +104 -0
- package/curated/literature/README.md +53 -0
- package/curated/research/README.md +62 -0
- package/curated/tools/README.md +87 -0
- package/curated/writing/README.md +61 -0
- package/index.ts +39 -0
- package/mcp-configs/academic-db/ChatSpatial.json +17 -0
- package/mcp-configs/academic-db/academia-mcp.json +17 -0
- package/mcp-configs/academic-db/academic-paper-explorer.json +17 -0
- package/mcp-configs/academic-db/academic-search-mcp-server.json +17 -0
- package/mcp-configs/academic-db/agentinterviews-mcp.json +17 -0
- package/mcp-configs/academic-db/all-in-mcp.json +17 -0
- package/mcp-configs/academic-db/apple-health-mcp.json +17 -0
- package/mcp-configs/academic-db/arxiv-latex-mcp.json +17 -0
- package/mcp-configs/academic-db/arxiv-mcp-server.json +17 -0
- package/mcp-configs/academic-db/bgpt-mcp.json +17 -0
- package/mcp-configs/academic-db/biomcp.json +17 -0
- package/mcp-configs/academic-db/biothings-mcp.json +17 -0
- package/mcp-configs/academic-db/catalysishub-mcp-server.json +17 -0
- package/mcp-configs/academic-db/clinicaltrialsgov-mcp-server.json +17 -0
- package/mcp-configs/academic-db/deep-research-mcp.json +17 -0
- package/mcp-configs/academic-db/dicom-mcp.json +17 -0
- package/mcp-configs/academic-db/enrichr-mcp-server.json +17 -0
- package/mcp-configs/academic-db/fec-mcp-server.json +17 -0
- package/mcp-configs/academic-db/fhir-mcp-server-themomentum.json +17 -0
- package/mcp-configs/academic-db/fhir-mcp.json +19 -0
- package/mcp-configs/academic-db/gget-mcp.json +17 -0
- package/mcp-configs/academic-db/google-researcher-mcp.json +17 -0
- package/mcp-configs/academic-db/idea-reality-mcp.json +17 -0
- package/mcp-configs/academic-db/legiscan-mcp.json +19 -0
- package/mcp-configs/academic-db/lex.json +17 -0
- package/mcp-configs/ai-platform/Adaptive-Graph-of-Thoughts-MCP-server.json +17 -0
- package/mcp-configs/ai-platform/ai-counsel.json +17 -0
- package/mcp-configs/ai-platform/atlas-mcp-server.json +17 -0
- package/mcp-configs/ai-platform/counsel-mcp.json +17 -0
- package/mcp-configs/ai-platform/cross-llm-mcp.json +17 -0
- package/mcp-configs/ai-platform/gptr-mcp.json +17 -0
- package/mcp-configs/browser/decipher-research-agent.json +17 -0
- package/mcp-configs/browser/deep-research.json +17 -0
- package/mcp-configs/browser/everything-claude-code.json +17 -0
- package/mcp-configs/browser/gpt-researcher.json +17 -0
- package/mcp-configs/browser/heurist-agent-framework.json +17 -0
- package/mcp-configs/data-platform/4everland-hosting-mcp.json +17 -0
- package/mcp-configs/data-platform/context-keeper.json +17 -0
- package/mcp-configs/data-platform/context7.json +19 -0
- package/mcp-configs/data-platform/contextstream-mcp.json +17 -0
- package/mcp-configs/data-platform/email-mcp.json +17 -0
- package/mcp-configs/note-knowledge/ApeRAG.json +17 -0
- package/mcp-configs/note-knowledge/In-Memoria.json +17 -0
- package/mcp-configs/note-knowledge/agent-memory.json +17 -0
- package/mcp-configs/note-knowledge/aimemo.json +17 -0
- package/mcp-configs/note-knowledge/biel-mcp.json +19 -0
- package/mcp-configs/note-knowledge/cognee.json +17 -0
- package/mcp-configs/note-knowledge/context-awesome.json +17 -0
- package/mcp-configs/note-knowledge/context-mcp.json +17 -0
- package/mcp-configs/note-knowledge/conversation-handoff-mcp.json +17 -0
- package/mcp-configs/note-knowledge/cortex.json +17 -0
- package/mcp-configs/note-knowledge/devrag.json +17 -0
- package/mcp-configs/note-knowledge/easy-obsidian-mcp.json +17 -0
- package/mcp-configs/note-knowledge/engram.json +17 -0
- package/mcp-configs/note-knowledge/gnosis-mcp.json +17 -0
- package/mcp-configs/note-knowledge/graphlit-mcp-server.json +19 -0
- package/mcp-configs/reference-mgr/arxiv-cli.json +17 -0
- package/mcp-configs/reference-mgr/arxiv-search-mcp.json +17 -0
- package/mcp-configs/reference-mgr/chiken.json +17 -0
- package/mcp-configs/reference-mgr/claude-scholar.json +17 -0
- package/mcp-configs/reference-mgr/devonthink-mcp.json +17 -0
- package/mcp-configs/registry.json +447 -0
- package/openclaw.plugin.json +21 -0
- package/package.json +61 -0
- package/skills/analysis/dataviz/color-accessibility-guide/SKILL.md +230 -0
- package/skills/analysis/dataviz/geospatial-viz-guide/SKILL.md +218 -0
- package/skills/analysis/dataviz/interactive-viz-guide/SKILL.md +287 -0
- package/skills/analysis/dataviz/network-visualization-guide/SKILL.md +195 -0
- package/skills/analysis/dataviz/publication-figures-guide/SKILL.md +238 -0
- package/skills/analysis/dataviz/python-dataviz-guide/SKILL.md +195 -0
- package/skills/analysis/econometrics/causal-inference-guide/SKILL.md +197 -0
- package/skills/analysis/econometrics/iv-regression-guide/SKILL.md +198 -0
- package/skills/analysis/econometrics/panel-data-guide/SKILL.md +274 -0
- package/skills/analysis/econometrics/robustness-checks/SKILL.md +250 -0
- package/skills/analysis/econometrics/stata-regression/SKILL.md +117 -0
- package/skills/analysis/econometrics/time-series-guide/SKILL.md +235 -0
- package/skills/analysis/statistics/bayesian-statistics-guide/SKILL.md +221 -0
- package/skills/analysis/statistics/hypothesis-testing-guide/SKILL.md +210 -0
- package/skills/analysis/statistics/meta-analysis-guide/SKILL.md +206 -0
- package/skills/analysis/statistics/nonparametric-tests-guide/SKILL.md +221 -0
- package/skills/analysis/statistics/power-analysis-guide/SKILL.md +240 -0
- package/skills/analysis/statistics/sem-guide/SKILL.md +231 -0
- package/skills/analysis/statistics/survival-analysis-guide/SKILL.md +195 -0
- package/skills/analysis/wrangling/missing-data-handling/SKILL.md +224 -0
- package/skills/analysis/wrangling/pandas-data-wrangling/SKILL.md +242 -0
- package/skills/analysis/wrangling/questionnaire-design-guide/SKILL.md +234 -0
- package/skills/analysis/wrangling/text-mining-guide/SKILL.md +225 -0
- package/skills/domains/ai-ml/computer-vision-guide/SKILL.md +213 -0
- package/skills/domains/ai-ml/deep-learning-papers-guide/SKILL.md +200 -0
- package/skills/domains/ai-ml/llm-evaluation-guide/SKILL.md +194 -0
- package/skills/domains/ai-ml/prompt-engineering-research/SKILL.md +233 -0
- package/skills/domains/ai-ml/reinforcement-learning-guide/SKILL.md +254 -0
- package/skills/domains/ai-ml/transformer-architecture-guide/SKILL.md +233 -0
- package/skills/domains/biomedical/clinical-research-guide/SKILL.md +232 -0
- package/skills/domains/biomedical/clinicaltrials-api/SKILL.md +177 -0
- package/skills/domains/biomedical/epidemiology-guide/SKILL.md +200 -0
- package/skills/domains/biomedical/genomics-analysis-guide/SKILL.md +270 -0
- package/skills/domains/business/market-analysis-guide/SKILL.md +112 -0
- package/skills/domains/business/strategic-management-guide/SKILL.md +154 -0
- package/skills/domains/chemistry/computational-chemistry-guide/SKILL.md +266 -0
- package/skills/domains/chemistry/retrosynthesis-guide/SKILL.md +215 -0
- package/skills/domains/cs/algorithms-complexity-guide/SKILL.md +194 -0
- package/skills/domains/cs/dblp-api/SKILL.md +129 -0
- package/skills/domains/cs/software-engineering-research/SKILL.md +218 -0
- package/skills/domains/ecology/biodiversity-data-guide/SKILL.md +296 -0
- package/skills/domains/ecology/conservation-biology-guide/SKILL.md +198 -0
- package/skills/domains/ecology/gbif-api/SKILL.md +158 -0
- package/skills/domains/ecology/inaturalist-api/SKILL.md +173 -0
- package/skills/domains/economics/behavioral-economics-guide/SKILL.md +239 -0
- package/skills/domains/economics/development-economics-guide/SKILL.md +181 -0
- package/skills/domains/economics/fred-api/SKILL.md +189 -0
- package/skills/domains/education/curriculum-design-guide/SKILL.md +144 -0
- package/skills/domains/education/learning-science-guide/SKILL.md +150 -0
- package/skills/domains/finance/financial-data-analysis/SKILL.md +152 -0
- package/skills/domains/finance/quantitative-finance-guide/SKILL.md +151 -0
- package/skills/domains/geoscience/climate-science-guide/SKILL.md +158 -0
- package/skills/domains/geoscience/gis-remote-sensing-guide/SKILL.md +129 -0
- package/skills/domains/humanities/digital-humanities-guide/SKILL.md +181 -0
- package/skills/domains/humanities/philosophy-research-guide/SKILL.md +148 -0
- package/skills/domains/law/courtlistener-api/SKILL.md +213 -0
- package/skills/domains/law/legal-research-guide/SKILL.md +250 -0
- package/skills/domains/math/linear-algebra-applications/SKILL.md +227 -0
- package/skills/domains/math/numerical-methods-guide/SKILL.md +236 -0
- package/skills/domains/math/oeis-api/SKILL.md +158 -0
- package/skills/domains/pharma/clinical-pharmacology-guide/SKILL.md +165 -0
- package/skills/domains/pharma/drug-development-guide/SKILL.md +177 -0
- package/skills/domains/physics/computational-physics-guide/SKILL.md +300 -0
- package/skills/domains/physics/nasa-ads-api/SKILL.md +150 -0
- package/skills/domains/physics/quantum-computing-guide/SKILL.md +234 -0
- package/skills/domains/social-science/social-research-methods/SKILL.md +194 -0
- package/skills/domains/social-science/survey-research-guide/SKILL.md +182 -0
- package/skills/literature/discovery/citation-alert-guide/SKILL.md +154 -0
- package/skills/literature/discovery/conference-proceedings-guide/SKILL.md +142 -0
- package/skills/literature/discovery/literature-mapping-guide/SKILL.md +175 -0
- package/skills/literature/discovery/paper-tracking-guide/SKILL.md +211 -0
- package/skills/literature/discovery/rss-paper-feeds/SKILL.md +214 -0
- package/skills/literature/discovery/semantic-scholar-recs-guide/SKILL.md +164 -0
- package/skills/literature/fulltext/doaj-api/SKILL.md +120 -0
- package/skills/literature/fulltext/interlibrary-loan-guide/SKILL.md +163 -0
- package/skills/literature/fulltext/open-access-guide/SKILL.md +183 -0
- package/skills/literature/fulltext/pmc-oai-api/SKILL.md +184 -0
- package/skills/literature/fulltext/preprint-servers-guide/SKILL.md +128 -0
- package/skills/literature/fulltext/repository-harvesting-guide/SKILL.md +207 -0
- package/skills/literature/fulltext/unpaywall-api/SKILL.md +113 -0
- package/skills/literature/metadata/altmetrics-guide/SKILL.md +132 -0
- package/skills/literature/metadata/citation-network-guide/SKILL.md +236 -0
- package/skills/literature/metadata/crossref-api/SKILL.md +133 -0
- package/skills/literature/metadata/datacite-api/SKILL.md +126 -0
- package/skills/literature/metadata/doi-resolution-guide/SKILL.md +168 -0
- package/skills/literature/metadata/h-index-guide/SKILL.md +183 -0
- package/skills/literature/metadata/journal-metrics-guide/SKILL.md +188 -0
- package/skills/literature/metadata/opencitations-api/SKILL.md +128 -0
- package/skills/literature/metadata/orcid-api/SKILL.md +136 -0
- package/skills/literature/metadata/orcid-integration-guide/SKILL.md +178 -0
- package/skills/literature/search/arxiv-api/SKILL.md +95 -0
- package/skills/literature/search/biorxiv-api/SKILL.md +123 -0
- package/skills/literature/search/boolean-search-guide/SKILL.md +199 -0
- package/skills/literature/search/citation-chaining-guide/SKILL.md +148 -0
- package/skills/literature/search/database-comparison-guide/SKILL.md +100 -0
- package/skills/literature/search/europe-pmc-api/SKILL.md +120 -0
- package/skills/literature/search/google-scholar-guide/SKILL.md +182 -0
- package/skills/literature/search/mesh-terms-guide/SKILL.md +164 -0
- package/skills/literature/search/openalex-api/SKILL.md +134 -0
- package/skills/literature/search/pubmed-api/SKILL.md +130 -0
- package/skills/literature/search/scientify-literature-survey/SKILL.md +203 -0
- package/skills/literature/search/semantic-scholar-api/SKILL.md +134 -0
- package/skills/literature/search/systematic-search-strategy/SKILL.md +214 -0
- package/skills/research/automation/ai-scientist-guide/SKILL.md +228 -0
- package/skills/research/automation/data-collection-automation/SKILL.md +248 -0
- package/skills/research/automation/research-workflow-automation/SKILL.md +266 -0
- package/skills/research/deep-research/meta-synthesis-guide/SKILL.md +174 -0
- package/skills/research/deep-research/research-cog/SKILL.md +153 -0
- package/skills/research/deep-research/scoping-review-guide/SKILL.md +217 -0
- package/skills/research/deep-research/systematic-review-guide/SKILL.md +250 -0
- package/skills/research/funding/figshare-api/SKILL.md +163 -0
- package/skills/research/funding/grant-writing-guide/SKILL.md +233 -0
- package/skills/research/funding/nsf-grant-guide/SKILL.md +206 -0
- package/skills/research/funding/open-science-guide/SKILL.md +255 -0
- package/skills/research/funding/zenodo-api/SKILL.md +174 -0
- package/skills/research/methodology/action-research-guide/SKILL.md +201 -0
- package/skills/research/methodology/experimental-design-guide/SKILL.md +236 -0
- package/skills/research/methodology/grad-school-guide/SKILL.md +182 -0
- package/skills/research/methodology/grounded-theory-guide/SKILL.md +171 -0
- package/skills/research/methodology/mixed-methods-guide/SKILL.md +208 -0
- package/skills/research/methodology/qualitative-research-guide/SKILL.md +234 -0
- package/skills/research/methodology/scientify-idea-generation/SKILL.md +222 -0
- package/skills/research/paper-review/paper-reading-assistant/SKILL.md +266 -0
- package/skills/research/paper-review/peer-review-guide/SKILL.md +227 -0
- package/skills/research/paper-review/rebuttal-writing-guide/SKILL.md +185 -0
- package/skills/research/paper-review/scientify-write-review-paper/SKILL.md +209 -0
- package/skills/tools/code-exec/jupyter-notebook-guide/SKILL.md +178 -0
- package/skills/tools/code-exec/python-reproducibility-guide/SKILL.md +341 -0
- package/skills/tools/code-exec/r-reproducibility-guide/SKILL.md +236 -0
- package/skills/tools/code-exec/sandbox-execution-guide/SKILL.md +221 -0
- package/skills/tools/diagram/mermaid-diagram-guide/SKILL.md +269 -0
- package/skills/tools/diagram/plantuml-guide/SKILL.md +397 -0
- package/skills/tools/diagram/scientific-illustration-guide/SKILL.md +225 -0
- package/skills/tools/document/anystyle-api/SKILL.md +199 -0
- package/skills/tools/document/grobid-pdf-parsing/SKILL.md +294 -0
- package/skills/tools/document/markdown-academic-guide/SKILL.md +217 -0
- package/skills/tools/document/pdf-extraction-guide/SKILL.md +321 -0
- package/skills/tools/knowledge-graph/knowledge-graph-construction/SKILL.md +306 -0
- package/skills/tools/knowledge-graph/ontology-design-guide/SKILL.md +214 -0
- package/skills/tools/knowledge-graph/rag-methodology-guide/SKILL.md +325 -0
- package/skills/tools/ocr-translate/formula-recognition-guide/SKILL.md +367 -0
- package/skills/tools/ocr-translate/handwriting-recognition-guide/SKILL.md +211 -0
- package/skills/tools/ocr-translate/latex-ocr-guide/SKILL.md +204 -0
- package/skills/tools/ocr-translate/multilingual-research-guide/SKILL.md +234 -0
- package/skills/tools/scraping/academic-web-scraping/SKILL.md +326 -0
- package/skills/tools/scraping/api-data-collection-guide/SKILL.md +301 -0
- package/skills/tools/scraping/web-scraping-ethics-guide/SKILL.md +250 -0
- package/skills/writing/citation/bibtex-management-guide/SKILL.md +246 -0
- package/skills/writing/citation/citation-style-guide/SKILL.md +248 -0
- package/skills/writing/citation/reference-manager-comparison/SKILL.md +208 -0
- package/skills/writing/citation/zotero-api/SKILL.md +188 -0
- package/skills/writing/composition/abstract-writing-guide/SKILL.md +188 -0
- package/skills/writing/composition/discussion-writing-guide/SKILL.md +194 -0
- package/skills/writing/composition/introduction-writing-guide/SKILL.md +194 -0
- package/skills/writing/composition/literature-review-writing/SKILL.md +196 -0
- package/skills/writing/composition/methods-section-guide/SKILL.md +185 -0
- package/skills/writing/composition/response-to-reviewers/SKILL.md +215 -0
- package/skills/writing/composition/scientific-writing-guide/SKILL.md +152 -0
- package/skills/writing/latex/bibliography-management-guide/SKILL.md +206 -0
- package/skills/writing/latex/latex-drawing-guide/SKILL.md +234 -0
- package/skills/writing/latex/latex-ecosystem-guide/SKILL.md +240 -0
- package/skills/writing/latex/math-typesetting-guide/SKILL.md +231 -0
- package/skills/writing/latex/overleaf-collaboration-guide/SKILL.md +211 -0
- package/skills/writing/latex/tikz-diagrams-guide/SKILL.md +211 -0
- package/skills/writing/polish/academic-translation-guide/SKILL.md +175 -0
- package/skills/writing/polish/academic-writing-refiner/SKILL.md +143 -0
- package/skills/writing/polish/ai-writing-humanizer/SKILL.md +178 -0
- package/skills/writing/polish/grammar-checker-guide/SKILL.md +184 -0
- package/skills/writing/polish/plagiarism-detection-guide/SKILL.md +167 -0
- package/skills/writing/templates/beamer-presentation-guide/SKILL.md +263 -0
- package/skills/writing/templates/conference-paper-template/SKILL.md +219 -0
- package/skills/writing/templates/thesis-template-guide/SKILL.md +200 -0
- package/skills/writing/templates/thesis-writing-guide/SKILL.md +220 -0
- package/src/tools/arxiv.ts +131 -0
- package/src/tools/crossref.ts +112 -0
- package/src/tools/openalex.ts +174 -0
- package/src/tools/pubmed.ts +166 -0
- package/src/tools/semantic-scholar.ts +108 -0
- package/src/tools/unpaywall.ts +58 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stata-regression
|
|
3
|
+
description: "Run regression analyses in Stata with publication-ready output"
|
|
4
|
+
metadata:
|
|
5
|
+
openclaw:
|
|
6
|
+
emoji: "📊"
|
|
7
|
+
category: "analysis"
|
|
8
|
+
subcategory: "econometrics"
|
|
9
|
+
keywords: ["Stata regression", "Stata data cleaning", "Stata commands", "panel data", "fixed effects", "robustness checks"]
|
|
10
|
+
source: "https://github.com/awesome-econ-ai/academic-skills"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Stata Regression
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
This skill produces reproducible regression analysis workflows in Stata, including model diagnostics and publication-ready tables using `esttab` or `outreg2`.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- Estimating linear or nonlinear regression models in Stata
|
|
22
|
+
- Producing tables for academic papers and reports
|
|
23
|
+
- Running robustness checks and alternative specifications
|
|
24
|
+
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
Follow these steps to complete the task:
|
|
28
|
+
|
|
29
|
+
### Step 1: Understand the Context
|
|
30
|
+
|
|
31
|
+
Before generating any code, ask the user:
|
|
32
|
+
- What is the dependent variable and key regressors?
|
|
33
|
+
- What controls and fixed effects are required?
|
|
34
|
+
- How should standard errors be clustered?
|
|
35
|
+
- What output format is needed (LaTeX, Word, or CSV)?
|
|
36
|
+
|
|
37
|
+
### Step 2: Generate the Output
|
|
38
|
+
|
|
39
|
+
Based on the context, generate Stata code that:
|
|
40
|
+
|
|
41
|
+
- **Loads and checks the data** - Handle missing values and verify variable types
|
|
42
|
+
- **Runs the requested specification** - Use `regress`, `reghdfe`, or `xtreg` as appropriate
|
|
43
|
+
- **Adds robust or clustered standard errors** - Match the study design
|
|
44
|
+
- **Exports tables** - Use `esttab` or `outreg2` with clear labels
|
|
45
|
+
|
|
46
|
+
### Step 3: Verify and Explain
|
|
47
|
+
|
|
48
|
+
After generating output:
|
|
49
|
+
- Explain what each model estimates
|
|
50
|
+
- Highlight assumptions and diagnostics
|
|
51
|
+
- Suggest robustness checks or alternative models
|
|
52
|
+
|
|
53
|
+
## Example Prompts
|
|
54
|
+
|
|
55
|
+
- "Run OLS with firm and year fixed effects, clustering by firm"
|
|
56
|
+
- "Estimate a logit model and export results to LaTeX"
|
|
57
|
+
- "Create a regression table with three specifications"
|
|
58
|
+
|
|
59
|
+
## Example Output
|
|
60
|
+
|
|
61
|
+
```stata
|
|
62
|
+
* ============================================
|
|
63
|
+
* Regression Analysis with Stata
|
|
64
|
+
* ============================================
|
|
65
|
+
|
|
66
|
+
* Load data
|
|
67
|
+
use "data.dta", clear
|
|
68
|
+
|
|
69
|
+
* Summary stats
|
|
70
|
+
summarize y x1 x2 x3
|
|
71
|
+
|
|
72
|
+
* Main regression with clustered SEs
|
|
73
|
+
regress y x1 x2 x3, vce(cluster firm_id)
|
|
74
|
+
eststo model1
|
|
75
|
+
|
|
76
|
+
* Alternative specification with fixed effects
|
|
77
|
+
reghdfe y x1 x2 x3, absorb(firm_id year) vce(cluster firm_id)
|
|
78
|
+
eststo model2
|
|
79
|
+
|
|
80
|
+
* Export table
|
|
81
|
+
esttab model1 model2 using "results/regression_table.tex", replace se label
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Requirements
|
|
85
|
+
|
|
86
|
+
### Software
|
|
87
|
+
|
|
88
|
+
- Stata 17+
|
|
89
|
+
|
|
90
|
+
### Packages
|
|
91
|
+
|
|
92
|
+
- `estout` (for `esttab`)
|
|
93
|
+
- `reghdfe` (optional, for high-dimensional fixed effects)
|
|
94
|
+
|
|
95
|
+
Install with:
|
|
96
|
+
```stata
|
|
97
|
+
ssc install estout
|
|
98
|
+
ssc install reghdfe
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Best Practices
|
|
102
|
+
|
|
103
|
+
- **Match standard errors to the design** (cluster where treatment varies)
|
|
104
|
+
- **Report all model variants** used in the analysis
|
|
105
|
+
- **Document variable definitions** and transformations
|
|
106
|
+
|
|
107
|
+
## Common Pitfalls
|
|
108
|
+
|
|
109
|
+
- Not clustering standard errors at the correct level
|
|
110
|
+
- Omitting fixed effects when required by the design
|
|
111
|
+
- Exporting tables without clear labels and notes
|
|
112
|
+
|
|
113
|
+
## References
|
|
114
|
+
|
|
115
|
+
- [Stata Regression Reference Manual](https://www.stata.com/manuals/rregress.pdf)
|
|
116
|
+
- [reghdfe documentation](https://github.com/sergiocorreia/reghdfe)
|
|
117
|
+
- [estout documentation](https://repec.sowi.unibe.ch/stata/estout/)
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: time-series-guide
|
|
3
|
+
description: "Apply ARIMA, VAR, cointegration, and time series econometric methods"
|
|
4
|
+
metadata:
|
|
5
|
+
openclaw:
|
|
6
|
+
emoji: "chart_with_downwards_trend"
|
|
7
|
+
category: "analysis"
|
|
8
|
+
subcategory: "econometrics"
|
|
9
|
+
keywords: ["time series", "ARIMA", "VAR", "cointegration", "stationarity", "forecasting", "econometrics"]
|
|
10
|
+
source: "wentor-research-plugins"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Time Series Guide
|
|
14
|
+
|
|
15
|
+
A skill for applying time series econometric methods including ARIMA modeling, VAR systems, cointegration analysis, and unit root tests. Covers stationarity concepts, model selection, forecasting, and diagnostic checking for economic and financial data.
|
|
16
|
+
|
|
17
|
+
## Stationarity and Unit Root Tests
|
|
18
|
+
|
|
19
|
+
### Why Stationarity Matters
|
|
20
|
+
|
|
21
|
+
A time series is stationary when its statistical properties (mean, variance, autocorrelation) do not change over time. Most econometric methods require stationarity. Non-stationary series can produce spurious regressions.
|
|
22
|
+
|
|
23
|
+
### Testing for Stationarity
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from statsmodels.tsa.stattools import adfuller, kpss
|
|
27
|
+
import pandas as pd
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_stationarity(series: pd.Series, name: str = "Series") -> dict:
|
|
31
|
+
"""
|
|
32
|
+
Test for stationarity using ADF and KPSS tests.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
series: Time series data
|
|
36
|
+
name: Label for the series
|
|
37
|
+
"""
|
|
38
|
+
# Augmented Dickey-Fuller test
|
|
39
|
+
# H0: Unit root exists (non-stationary)
|
|
40
|
+
adf_result = adfuller(series.dropna(), autolag="AIC")
|
|
41
|
+
|
|
42
|
+
# KPSS test
|
|
43
|
+
# H0: Series is stationary
|
|
44
|
+
kpss_result = kpss(series.dropna(), regression="c", nlags="auto")
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
"series": name,
|
|
48
|
+
"adf": {
|
|
49
|
+
"statistic": adf_result[0],
|
|
50
|
+
"p_value": adf_result[1],
|
|
51
|
+
"lags_used": adf_result[2],
|
|
52
|
+
"conclusion": (
|
|
53
|
+
"Stationary (reject unit root)"
|
|
54
|
+
if adf_result[1] < 0.05
|
|
55
|
+
else "Non-stationary (fail to reject unit root)"
|
|
56
|
+
)
|
|
57
|
+
},
|
|
58
|
+
"kpss": {
|
|
59
|
+
"statistic": kpss_result[0],
|
|
60
|
+
"p_value": kpss_result[1],
|
|
61
|
+
"conclusion": (
|
|
62
|
+
"Non-stationary (reject stationarity)"
|
|
63
|
+
if kpss_result[1] < 0.05
|
|
64
|
+
else "Stationary (fail to reject stationarity)"
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Making a Series Stationary
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Method 1: Differencing
|
|
74
|
+
y_diff = y_t - y_{t-1} (first difference)
|
|
75
|
+
y_diff2 = delta(y_diff) (second difference, rarely needed)
|
|
76
|
+
|
|
77
|
+
Method 2: Log transformation + differencing
|
|
78
|
+
y_log = log(y_t) (stabilizes variance)
|
|
79
|
+
y_return = log(y_t) - log(y_{t-1}) (log returns)
|
|
80
|
+
|
|
81
|
+
Method 3: Detrending
|
|
82
|
+
Subtract a fitted trend (linear, polynomial, or HP filter)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## ARIMA Modeling
|
|
86
|
+
|
|
87
|
+
### Model Structure
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
ARIMA(p, d, q):
|
|
91
|
+
p = order of autoregressive (AR) component
|
|
92
|
+
d = degree of differencing
|
|
93
|
+
q = order of moving average (MA) component
|
|
94
|
+
|
|
95
|
+
SARIMA(p, d, q)(P, D, Q, s):
|
|
96
|
+
Seasonal extension with period s
|
|
97
|
+
P, D, Q = seasonal AR, differencing, MA orders
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Model Selection and Fitting
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from statsmodels.tsa.arima.model import ARIMA
|
|
104
|
+
import numpy as np
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def fit_arima(series: pd.Series, order: tuple = None) -> dict:
|
|
108
|
+
"""
|
|
109
|
+
Fit an ARIMA model, optionally using auto-selection.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
series: Time series data
|
|
113
|
+
order: (p, d, q) tuple; if None, uses AIC-based selection
|
|
114
|
+
"""
|
|
115
|
+
if order is None:
|
|
116
|
+
# Grid search over common orders
|
|
117
|
+
best_aic = np.inf
|
|
118
|
+
best_order = (0, 0, 0)
|
|
119
|
+
for p in range(4):
|
|
120
|
+
for d in range(3):
|
|
121
|
+
for q in range(4):
|
|
122
|
+
try:
|
|
123
|
+
model = ARIMA(series, order=(p, d, q))
|
|
124
|
+
result = model.fit()
|
|
125
|
+
if result.aic < best_aic:
|
|
126
|
+
best_aic = result.aic
|
|
127
|
+
best_order = (p, d, q)
|
|
128
|
+
except Exception:
|
|
129
|
+
continue
|
|
130
|
+
order = best_order
|
|
131
|
+
|
|
132
|
+
model = ARIMA(series, order=order)
|
|
133
|
+
result = model.fit()
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
"order": order,
|
|
137
|
+
"aic": result.aic,
|
|
138
|
+
"bic": result.bic,
|
|
139
|
+
"coefficients": dict(zip(result.param_names, result.params)),
|
|
140
|
+
"residual_diagnostics": {
|
|
141
|
+
"ljung_box_p": float(
|
|
142
|
+
result.test_serial_correlation("ljungbox", lags=[10])[0]["lb_pvalue"].iloc[0]
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Vector Autoregression (VAR)
|
|
149
|
+
|
|
150
|
+
### Multivariate Time Series
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from statsmodels.tsa.api import VAR
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def fit_var_model(data: pd.DataFrame, maxlags: int = 12) -> dict:
|
|
157
|
+
"""
|
|
158
|
+
Fit a VAR model to multivariate time series data.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
data: DataFrame with multiple time series columns
|
|
162
|
+
maxlags: Maximum lag order to consider
|
|
163
|
+
"""
|
|
164
|
+
model = VAR(data)
|
|
165
|
+
|
|
166
|
+
# Select lag order by information criteria
|
|
167
|
+
lag_selection = model.select_order(maxlags=maxlags)
|
|
168
|
+
optimal_lag = lag_selection.aic
|
|
169
|
+
|
|
170
|
+
result = model.fit(optimal_lag)
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
"lag_order": optimal_lag,
|
|
174
|
+
"aic": result.aic,
|
|
175
|
+
"variables": list(data.columns),
|
|
176
|
+
"granger_causality": "Use result.test_causality() for pairwise tests",
|
|
177
|
+
"irf": "Use result.irf(periods=20) for impulse response functions"
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Granger Causality
|
|
182
|
+
|
|
183
|
+
Granger causality tests whether past values of variable X improve forecasts of variable Y beyond what past values of Y alone provide. It is a test of predictive precedence, not true causation.
|
|
184
|
+
|
|
185
|
+
## Cointegration Analysis
|
|
186
|
+
|
|
187
|
+
### Engle-Granger and Johansen Tests
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from statsmodels.tsa.stattools import coint
|
|
191
|
+
from statsmodels.tsa.vector_ar.vecm import coint_johansen
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_cointegration(y1: pd.Series, y2: pd.Series) -> dict:
|
|
195
|
+
"""
|
|
196
|
+
Test for cointegration between two series.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
y1: First time series
|
|
200
|
+
y2: Second time series
|
|
201
|
+
"""
|
|
202
|
+
# Engle-Granger two-step test
|
|
203
|
+
eg_stat, eg_pvalue, eg_crit = coint(y1, y2)
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
"engle_granger": {
|
|
207
|
+
"statistic": eg_stat,
|
|
208
|
+
"p_value": eg_pvalue,
|
|
209
|
+
"conclusion": (
|
|
210
|
+
"Cointegrated" if eg_pvalue < 0.05
|
|
211
|
+
else "Not cointegrated"
|
|
212
|
+
)
|
|
213
|
+
},
|
|
214
|
+
"interpretation": (
|
|
215
|
+
"If cointegrated, these series share a long-run equilibrium "
|
|
216
|
+
"relationship. Use a Vector Error Correction Model (VECM) "
|
|
217
|
+
"rather than a VAR in differences."
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Diagnostic Checking
|
|
223
|
+
|
|
224
|
+
### Model Validation Checklist
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
1. Residual autocorrelation: Ljung-Box test (should be non-significant)
|
|
228
|
+
2. Residual normality: Jarque-Bera test or Q-Q plot
|
|
229
|
+
3. Heteroskedasticity: ARCH-LM test for conditional heteroskedasticity
|
|
230
|
+
4. Stability: Check that AR roots lie inside the unit circle
|
|
231
|
+
5. Forecast accuracy: Out-of-sample RMSE, MAE, MAPE
|
|
232
|
+
6. Information criteria: Compare AIC/BIC across candidate models
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Report all diagnostic results in your paper. Reviewers expect evidence that residuals are well-behaved and that the chosen model specification is justified by information criteria and domain knowledge.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bayesian-statistics-guide
|
|
3
|
+
description: "Bayesian inference methods including prior selection, MCMC, and model comparison"
|
|
4
|
+
metadata:
|
|
5
|
+
openclaw:
|
|
6
|
+
emoji: "triangular_ruler"
|
|
7
|
+
category: "analysis"
|
|
8
|
+
subcategory: "statistics"
|
|
9
|
+
keywords: ["Bayesian statistics", "Bayesian inference", "MCMC", "sample size calculation", "prior selection"]
|
|
10
|
+
source: "wentor"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Bayesian Statistics Guide
|
|
14
|
+
|
|
15
|
+
A skill for applying Bayesian statistical methods to research data analysis. Covers prior specification, Markov chain Monte Carlo (MCMC) sampling, posterior interpretation, model comparison, and reporting standards.
|
|
16
|
+
|
|
17
|
+
## Bayesian Framework Overview
|
|
18
|
+
|
|
19
|
+
### Bayes' Theorem in Practice
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Posterior = (Likelihood x Prior) / Evidence
|
|
23
|
+
|
|
24
|
+
P(theta | data) = P(data | theta) * P(theta) / P(data)
|
|
25
|
+
|
|
26
|
+
In practice:
|
|
27
|
+
P(theta | data) is proportional to P(data | theta) * P(theta)
|
|
28
|
+
(the denominator is a normalizing constant)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### When to Use Bayesian Methods
|
|
32
|
+
|
|
33
|
+
| Scenario | Bayesian Advantage |
|
|
34
|
+
|----------|-------------------|
|
|
35
|
+
| Small sample sizes | Priors regularize estimates |
|
|
36
|
+
| Complex hierarchical models | Natural framework for multilevel data |
|
|
37
|
+
| Sequential data collection | Update beliefs as data arrives |
|
|
38
|
+
| Prior knowledge available | Formally incorporate existing evidence |
|
|
39
|
+
| Model comparison | Bayes factors and posterior model probabilities |
|
|
40
|
+
| Prediction | Full posterior predictive distributions |
|
|
41
|
+
|
|
42
|
+
## Prior Specification
|
|
43
|
+
|
|
44
|
+
### Types of Priors
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import numpy as np
|
|
48
|
+
from scipy import stats
|
|
49
|
+
import matplotlib.pyplot as plt
|
|
50
|
+
|
|
51
|
+
def visualize_priors(parameter_name: str, prior_type: str = 'weakly_informative'):
|
|
52
|
+
"""
|
|
53
|
+
Visualize common prior choices for a parameter.
|
|
54
|
+
"""
|
|
55
|
+
x = np.linspace(-10, 10, 1000)
|
|
56
|
+
|
|
57
|
+
priors = {
|
|
58
|
+
'flat': {
|
|
59
|
+
'dist': stats.uniform(loc=-100, scale=200),
|
|
60
|
+
'description': 'Flat/Uniform: minimal prior info (often improper)',
|
|
61
|
+
'recommendation': 'Avoid -- can lead to improper posteriors'
|
|
62
|
+
},
|
|
63
|
+
'weakly_informative': {
|
|
64
|
+
'dist': stats.norm(loc=0, scale=2.5),
|
|
65
|
+
'description': 'Weakly informative: Normal(0, 2.5)',
|
|
66
|
+
'recommendation': 'Good default for regression coefficients'
|
|
67
|
+
},
|
|
68
|
+
'informative': {
|
|
69
|
+
'dist': stats.norm(loc=0.5, scale=0.2),
|
|
70
|
+
'description': 'Informative: based on previous studies',
|
|
71
|
+
'recommendation': 'Use when strong prior evidence exists'
|
|
72
|
+
},
|
|
73
|
+
'horseshoe': {
|
|
74
|
+
'dist': stats.cauchy(loc=0, scale=1),
|
|
75
|
+
'description': 'Horseshoe-like (Cauchy): sparsity-inducing',
|
|
76
|
+
'recommendation': 'Good for variable selection problems'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
prior = priors.get(prior_type, priors['weakly_informative'])
|
|
81
|
+
return prior
|
|
82
|
+
|
|
83
|
+
# Recommended default priors (Gelman et al., 2008):
|
|
84
|
+
# Intercept: Normal(0, 10)
|
|
85
|
+
# Coefficients: Normal(0, 2.5) on standardized predictors
|
|
86
|
+
# Standard deviation: Half-Cauchy(0, 2.5) or Exponential(1)
|
|
87
|
+
# Correlation: LKJ(2) for correlation matrices
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## MCMC with PyMC
|
|
91
|
+
|
|
92
|
+
### Linear Regression Example
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import pymc as pm
|
|
96
|
+
import arviz as az
|
|
97
|
+
|
|
98
|
+
def bayesian_regression(X, y, feature_names=None):
|
|
99
|
+
"""
|
|
100
|
+
Fit a Bayesian linear regression model using PyMC.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
X: Feature matrix (n_samples, n_features)
|
|
104
|
+
y: Response variable (n_samples,)
|
|
105
|
+
feature_names: List of feature names
|
|
106
|
+
"""
|
|
107
|
+
n_features = X.shape[1]
|
|
108
|
+
if feature_names is None:
|
|
109
|
+
feature_names = [f'x{i}' for i in range(n_features)]
|
|
110
|
+
|
|
111
|
+
with pm.Model() as model:
|
|
112
|
+
# Priors
|
|
113
|
+
intercept = pm.Normal('intercept', mu=0, sigma=10)
|
|
114
|
+
betas = pm.Normal('betas', mu=0, sigma=2.5, shape=n_features)
|
|
115
|
+
sigma = pm.HalfCauchy('sigma', beta=2.5)
|
|
116
|
+
|
|
117
|
+
# Linear predictor
|
|
118
|
+
mu = intercept + pm.math.dot(X, betas)
|
|
119
|
+
|
|
120
|
+
# Likelihood
|
|
121
|
+
y_obs = pm.Normal('y_obs', mu=mu, sigma=sigma, observed=y)
|
|
122
|
+
|
|
123
|
+
# MCMC sampling
|
|
124
|
+
trace = pm.sample(
|
|
125
|
+
draws=2000,
|
|
126
|
+
tune=1000,
|
|
127
|
+
chains=4,
|
|
128
|
+
cores=4,
|
|
129
|
+
target_accept=0.9,
|
|
130
|
+
return_inferencedata=True
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
return model, trace
|
|
134
|
+
|
|
135
|
+
# After fitting, analyze results:
|
|
136
|
+
# az.summary(trace, var_names=['intercept', 'betas', 'sigma'])
|
|
137
|
+
# az.plot_trace(trace)
|
|
138
|
+
# az.plot_forest(trace, var_names=['betas'])
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Diagnostics
|
|
142
|
+
|
|
143
|
+
### MCMC Convergence Checks
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
def check_mcmc_diagnostics(trace) -> dict:
|
|
147
|
+
"""
|
|
148
|
+
Check MCMC convergence diagnostics.
|
|
149
|
+
"""
|
|
150
|
+
summary = az.summary(trace)
|
|
151
|
+
|
|
152
|
+
diagnostics = {
|
|
153
|
+
'r_hat': {
|
|
154
|
+
'values': summary['r_hat'].to_dict(),
|
|
155
|
+
'threshold': 1.01,
|
|
156
|
+
'pass': (summary['r_hat'] < 1.01).all(),
|
|
157
|
+
'interpretation': 'R-hat < 1.01 indicates convergence'
|
|
158
|
+
},
|
|
159
|
+
'ess_bulk': {
|
|
160
|
+
'min_value': summary['ess_bulk'].min(),
|
|
161
|
+
'threshold': 400,
|
|
162
|
+
'pass': (summary['ess_bulk'] > 400).all(),
|
|
163
|
+
'interpretation': 'ESS > 400 ensures reliable posterior estimates'
|
|
164
|
+
},
|
|
165
|
+
'ess_tail': {
|
|
166
|
+
'min_value': summary['ess_tail'].min(),
|
|
167
|
+
'threshold': 400,
|
|
168
|
+
'pass': (summary['ess_tail'] > 400).all(),
|
|
169
|
+
'interpretation': 'Tail ESS > 400 ensures reliable credible intervals'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
# Overall assessment
|
|
174
|
+
diagnostics['converged'] = all(
|
|
175
|
+
d['pass'] for d in diagnostics.values() if 'pass' in d
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return diagnostics
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Model Comparison
|
|
182
|
+
|
|
183
|
+
### Bayesian Model Selection
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
def compare_models(traces: dict) -> dict:
|
|
187
|
+
"""
|
|
188
|
+
Compare Bayesian models using LOO-CV and WAIC.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
traces: Dict mapping model names to InferenceData objects
|
|
192
|
+
"""
|
|
193
|
+
comparison = az.compare(traces, ic='loo')
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
'ranking': comparison.index.tolist(),
|
|
197
|
+
'loo_values': comparison['loo'].to_dict(),
|
|
198
|
+
'weights': comparison['weight'].to_dict(),
|
|
199
|
+
'interpretation': (
|
|
200
|
+
f"Best model: {comparison.index[0]} "
|
|
201
|
+
f"(weight = {comparison['weight'].iloc[0]:.2f})"
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Reporting Bayesian Results
|
|
207
|
+
|
|
208
|
+
Follow the WAMBS checklist (Depaoli & van de Schoot, 2017):
|
|
209
|
+
|
|
210
|
+
1. **Priors**: Report all prior distributions and justify choices
|
|
211
|
+
2. **Convergence**: Report R-hat, ESS, and trace plots (in supplement)
|
|
212
|
+
3. **Posteriors**: Report posterior mean/median, 95% credible interval (HDI preferred)
|
|
213
|
+
4. **Sensitivity**: Show results are robust to reasonable prior changes
|
|
214
|
+
5. **Model fit**: Report LOO-IC, WAIC, or posterior predictive checks
|
|
215
|
+
|
|
216
|
+
Example results sentence: "The effect of treatment on outcome was estimated at beta = 0.45, 95% HDI [0.21, 0.68], with a posterior probability of 0.99 that the effect is positive."
|
|
217
|
+
|
|
218
|
+
## References
|
|
219
|
+
|
|
220
|
+
- Gelman, A., et al. (2013). *Bayesian Data Analysis* (3rd ed.). CRC Press.
|
|
221
|
+
- McElreath, R. (2020). *Statistical Rethinking* (2nd ed.). CRC Press.
|