@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.
Files changed (252) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -0
  3. package/curated/analysis/README.md +64 -0
  4. package/curated/domains/README.md +104 -0
  5. package/curated/literature/README.md +53 -0
  6. package/curated/research/README.md +62 -0
  7. package/curated/tools/README.md +87 -0
  8. package/curated/writing/README.md +61 -0
  9. package/index.ts +39 -0
  10. package/mcp-configs/academic-db/ChatSpatial.json +17 -0
  11. package/mcp-configs/academic-db/academia-mcp.json +17 -0
  12. package/mcp-configs/academic-db/academic-paper-explorer.json +17 -0
  13. package/mcp-configs/academic-db/academic-search-mcp-server.json +17 -0
  14. package/mcp-configs/academic-db/agentinterviews-mcp.json +17 -0
  15. package/mcp-configs/academic-db/all-in-mcp.json +17 -0
  16. package/mcp-configs/academic-db/apple-health-mcp.json +17 -0
  17. package/mcp-configs/academic-db/arxiv-latex-mcp.json +17 -0
  18. package/mcp-configs/academic-db/arxiv-mcp-server.json +17 -0
  19. package/mcp-configs/academic-db/bgpt-mcp.json +17 -0
  20. package/mcp-configs/academic-db/biomcp.json +17 -0
  21. package/mcp-configs/academic-db/biothings-mcp.json +17 -0
  22. package/mcp-configs/academic-db/catalysishub-mcp-server.json +17 -0
  23. package/mcp-configs/academic-db/clinicaltrialsgov-mcp-server.json +17 -0
  24. package/mcp-configs/academic-db/deep-research-mcp.json +17 -0
  25. package/mcp-configs/academic-db/dicom-mcp.json +17 -0
  26. package/mcp-configs/academic-db/enrichr-mcp-server.json +17 -0
  27. package/mcp-configs/academic-db/fec-mcp-server.json +17 -0
  28. package/mcp-configs/academic-db/fhir-mcp-server-themomentum.json +17 -0
  29. package/mcp-configs/academic-db/fhir-mcp.json +19 -0
  30. package/mcp-configs/academic-db/gget-mcp.json +17 -0
  31. package/mcp-configs/academic-db/google-researcher-mcp.json +17 -0
  32. package/mcp-configs/academic-db/idea-reality-mcp.json +17 -0
  33. package/mcp-configs/academic-db/legiscan-mcp.json +19 -0
  34. package/mcp-configs/academic-db/lex.json +17 -0
  35. package/mcp-configs/ai-platform/Adaptive-Graph-of-Thoughts-MCP-server.json +17 -0
  36. package/mcp-configs/ai-platform/ai-counsel.json +17 -0
  37. package/mcp-configs/ai-platform/atlas-mcp-server.json +17 -0
  38. package/mcp-configs/ai-platform/counsel-mcp.json +17 -0
  39. package/mcp-configs/ai-platform/cross-llm-mcp.json +17 -0
  40. package/mcp-configs/ai-platform/gptr-mcp.json +17 -0
  41. package/mcp-configs/browser/decipher-research-agent.json +17 -0
  42. package/mcp-configs/browser/deep-research.json +17 -0
  43. package/mcp-configs/browser/everything-claude-code.json +17 -0
  44. package/mcp-configs/browser/gpt-researcher.json +17 -0
  45. package/mcp-configs/browser/heurist-agent-framework.json +17 -0
  46. package/mcp-configs/data-platform/4everland-hosting-mcp.json +17 -0
  47. package/mcp-configs/data-platform/context-keeper.json +17 -0
  48. package/mcp-configs/data-platform/context7.json +19 -0
  49. package/mcp-configs/data-platform/contextstream-mcp.json +17 -0
  50. package/mcp-configs/data-platform/email-mcp.json +17 -0
  51. package/mcp-configs/note-knowledge/ApeRAG.json +17 -0
  52. package/mcp-configs/note-knowledge/In-Memoria.json +17 -0
  53. package/mcp-configs/note-knowledge/agent-memory.json +17 -0
  54. package/mcp-configs/note-knowledge/aimemo.json +17 -0
  55. package/mcp-configs/note-knowledge/biel-mcp.json +19 -0
  56. package/mcp-configs/note-knowledge/cognee.json +17 -0
  57. package/mcp-configs/note-knowledge/context-awesome.json +17 -0
  58. package/mcp-configs/note-knowledge/context-mcp.json +17 -0
  59. package/mcp-configs/note-knowledge/conversation-handoff-mcp.json +17 -0
  60. package/mcp-configs/note-knowledge/cortex.json +17 -0
  61. package/mcp-configs/note-knowledge/devrag.json +17 -0
  62. package/mcp-configs/note-knowledge/easy-obsidian-mcp.json +17 -0
  63. package/mcp-configs/note-knowledge/engram.json +17 -0
  64. package/mcp-configs/note-knowledge/gnosis-mcp.json +17 -0
  65. package/mcp-configs/note-knowledge/graphlit-mcp-server.json +19 -0
  66. package/mcp-configs/reference-mgr/arxiv-cli.json +17 -0
  67. package/mcp-configs/reference-mgr/arxiv-search-mcp.json +17 -0
  68. package/mcp-configs/reference-mgr/chiken.json +17 -0
  69. package/mcp-configs/reference-mgr/claude-scholar.json +17 -0
  70. package/mcp-configs/reference-mgr/devonthink-mcp.json +17 -0
  71. package/mcp-configs/registry.json +447 -0
  72. package/openclaw.plugin.json +21 -0
  73. package/package.json +61 -0
  74. package/skills/analysis/dataviz/color-accessibility-guide/SKILL.md +230 -0
  75. package/skills/analysis/dataviz/geospatial-viz-guide/SKILL.md +218 -0
  76. package/skills/analysis/dataviz/interactive-viz-guide/SKILL.md +287 -0
  77. package/skills/analysis/dataviz/network-visualization-guide/SKILL.md +195 -0
  78. package/skills/analysis/dataviz/publication-figures-guide/SKILL.md +238 -0
  79. package/skills/analysis/dataviz/python-dataviz-guide/SKILL.md +195 -0
  80. package/skills/analysis/econometrics/causal-inference-guide/SKILL.md +197 -0
  81. package/skills/analysis/econometrics/iv-regression-guide/SKILL.md +198 -0
  82. package/skills/analysis/econometrics/panel-data-guide/SKILL.md +274 -0
  83. package/skills/analysis/econometrics/robustness-checks/SKILL.md +250 -0
  84. package/skills/analysis/econometrics/stata-regression/SKILL.md +117 -0
  85. package/skills/analysis/econometrics/time-series-guide/SKILL.md +235 -0
  86. package/skills/analysis/statistics/bayesian-statistics-guide/SKILL.md +221 -0
  87. package/skills/analysis/statistics/hypothesis-testing-guide/SKILL.md +210 -0
  88. package/skills/analysis/statistics/meta-analysis-guide/SKILL.md +206 -0
  89. package/skills/analysis/statistics/nonparametric-tests-guide/SKILL.md +221 -0
  90. package/skills/analysis/statistics/power-analysis-guide/SKILL.md +240 -0
  91. package/skills/analysis/statistics/sem-guide/SKILL.md +231 -0
  92. package/skills/analysis/statistics/survival-analysis-guide/SKILL.md +195 -0
  93. package/skills/analysis/wrangling/missing-data-handling/SKILL.md +224 -0
  94. package/skills/analysis/wrangling/pandas-data-wrangling/SKILL.md +242 -0
  95. package/skills/analysis/wrangling/questionnaire-design-guide/SKILL.md +234 -0
  96. package/skills/analysis/wrangling/text-mining-guide/SKILL.md +225 -0
  97. package/skills/domains/ai-ml/computer-vision-guide/SKILL.md +213 -0
  98. package/skills/domains/ai-ml/deep-learning-papers-guide/SKILL.md +200 -0
  99. package/skills/domains/ai-ml/llm-evaluation-guide/SKILL.md +194 -0
  100. package/skills/domains/ai-ml/prompt-engineering-research/SKILL.md +233 -0
  101. package/skills/domains/ai-ml/reinforcement-learning-guide/SKILL.md +254 -0
  102. package/skills/domains/ai-ml/transformer-architecture-guide/SKILL.md +233 -0
  103. package/skills/domains/biomedical/clinical-research-guide/SKILL.md +232 -0
  104. package/skills/domains/biomedical/clinicaltrials-api/SKILL.md +177 -0
  105. package/skills/domains/biomedical/epidemiology-guide/SKILL.md +200 -0
  106. package/skills/domains/biomedical/genomics-analysis-guide/SKILL.md +270 -0
  107. package/skills/domains/business/market-analysis-guide/SKILL.md +112 -0
  108. package/skills/domains/business/strategic-management-guide/SKILL.md +154 -0
  109. package/skills/domains/chemistry/computational-chemistry-guide/SKILL.md +266 -0
  110. package/skills/domains/chemistry/retrosynthesis-guide/SKILL.md +215 -0
  111. package/skills/domains/cs/algorithms-complexity-guide/SKILL.md +194 -0
  112. package/skills/domains/cs/dblp-api/SKILL.md +129 -0
  113. package/skills/domains/cs/software-engineering-research/SKILL.md +218 -0
  114. package/skills/domains/ecology/biodiversity-data-guide/SKILL.md +296 -0
  115. package/skills/domains/ecology/conservation-biology-guide/SKILL.md +198 -0
  116. package/skills/domains/ecology/gbif-api/SKILL.md +158 -0
  117. package/skills/domains/ecology/inaturalist-api/SKILL.md +173 -0
  118. package/skills/domains/economics/behavioral-economics-guide/SKILL.md +239 -0
  119. package/skills/domains/economics/development-economics-guide/SKILL.md +181 -0
  120. package/skills/domains/economics/fred-api/SKILL.md +189 -0
  121. package/skills/domains/education/curriculum-design-guide/SKILL.md +144 -0
  122. package/skills/domains/education/learning-science-guide/SKILL.md +150 -0
  123. package/skills/domains/finance/financial-data-analysis/SKILL.md +152 -0
  124. package/skills/domains/finance/quantitative-finance-guide/SKILL.md +151 -0
  125. package/skills/domains/geoscience/climate-science-guide/SKILL.md +158 -0
  126. package/skills/domains/geoscience/gis-remote-sensing-guide/SKILL.md +129 -0
  127. package/skills/domains/humanities/digital-humanities-guide/SKILL.md +181 -0
  128. package/skills/domains/humanities/philosophy-research-guide/SKILL.md +148 -0
  129. package/skills/domains/law/courtlistener-api/SKILL.md +213 -0
  130. package/skills/domains/law/legal-research-guide/SKILL.md +250 -0
  131. package/skills/domains/math/linear-algebra-applications/SKILL.md +227 -0
  132. package/skills/domains/math/numerical-methods-guide/SKILL.md +236 -0
  133. package/skills/domains/math/oeis-api/SKILL.md +158 -0
  134. package/skills/domains/pharma/clinical-pharmacology-guide/SKILL.md +165 -0
  135. package/skills/domains/pharma/drug-development-guide/SKILL.md +177 -0
  136. package/skills/domains/physics/computational-physics-guide/SKILL.md +300 -0
  137. package/skills/domains/physics/nasa-ads-api/SKILL.md +150 -0
  138. package/skills/domains/physics/quantum-computing-guide/SKILL.md +234 -0
  139. package/skills/domains/social-science/social-research-methods/SKILL.md +194 -0
  140. package/skills/domains/social-science/survey-research-guide/SKILL.md +182 -0
  141. package/skills/literature/discovery/citation-alert-guide/SKILL.md +154 -0
  142. package/skills/literature/discovery/conference-proceedings-guide/SKILL.md +142 -0
  143. package/skills/literature/discovery/literature-mapping-guide/SKILL.md +175 -0
  144. package/skills/literature/discovery/paper-tracking-guide/SKILL.md +211 -0
  145. package/skills/literature/discovery/rss-paper-feeds/SKILL.md +214 -0
  146. package/skills/literature/discovery/semantic-scholar-recs-guide/SKILL.md +164 -0
  147. package/skills/literature/fulltext/doaj-api/SKILL.md +120 -0
  148. package/skills/literature/fulltext/interlibrary-loan-guide/SKILL.md +163 -0
  149. package/skills/literature/fulltext/open-access-guide/SKILL.md +183 -0
  150. package/skills/literature/fulltext/pmc-oai-api/SKILL.md +184 -0
  151. package/skills/literature/fulltext/preprint-servers-guide/SKILL.md +128 -0
  152. package/skills/literature/fulltext/repository-harvesting-guide/SKILL.md +207 -0
  153. package/skills/literature/fulltext/unpaywall-api/SKILL.md +113 -0
  154. package/skills/literature/metadata/altmetrics-guide/SKILL.md +132 -0
  155. package/skills/literature/metadata/citation-network-guide/SKILL.md +236 -0
  156. package/skills/literature/metadata/crossref-api/SKILL.md +133 -0
  157. package/skills/literature/metadata/datacite-api/SKILL.md +126 -0
  158. package/skills/literature/metadata/doi-resolution-guide/SKILL.md +168 -0
  159. package/skills/literature/metadata/h-index-guide/SKILL.md +183 -0
  160. package/skills/literature/metadata/journal-metrics-guide/SKILL.md +188 -0
  161. package/skills/literature/metadata/opencitations-api/SKILL.md +128 -0
  162. package/skills/literature/metadata/orcid-api/SKILL.md +136 -0
  163. package/skills/literature/metadata/orcid-integration-guide/SKILL.md +178 -0
  164. package/skills/literature/search/arxiv-api/SKILL.md +95 -0
  165. package/skills/literature/search/biorxiv-api/SKILL.md +123 -0
  166. package/skills/literature/search/boolean-search-guide/SKILL.md +199 -0
  167. package/skills/literature/search/citation-chaining-guide/SKILL.md +148 -0
  168. package/skills/literature/search/database-comparison-guide/SKILL.md +100 -0
  169. package/skills/literature/search/europe-pmc-api/SKILL.md +120 -0
  170. package/skills/literature/search/google-scholar-guide/SKILL.md +182 -0
  171. package/skills/literature/search/mesh-terms-guide/SKILL.md +164 -0
  172. package/skills/literature/search/openalex-api/SKILL.md +134 -0
  173. package/skills/literature/search/pubmed-api/SKILL.md +130 -0
  174. package/skills/literature/search/scientify-literature-survey/SKILL.md +203 -0
  175. package/skills/literature/search/semantic-scholar-api/SKILL.md +134 -0
  176. package/skills/literature/search/systematic-search-strategy/SKILL.md +214 -0
  177. package/skills/research/automation/ai-scientist-guide/SKILL.md +228 -0
  178. package/skills/research/automation/data-collection-automation/SKILL.md +248 -0
  179. package/skills/research/automation/research-workflow-automation/SKILL.md +266 -0
  180. package/skills/research/deep-research/meta-synthesis-guide/SKILL.md +174 -0
  181. package/skills/research/deep-research/research-cog/SKILL.md +153 -0
  182. package/skills/research/deep-research/scoping-review-guide/SKILL.md +217 -0
  183. package/skills/research/deep-research/systematic-review-guide/SKILL.md +250 -0
  184. package/skills/research/funding/figshare-api/SKILL.md +163 -0
  185. package/skills/research/funding/grant-writing-guide/SKILL.md +233 -0
  186. package/skills/research/funding/nsf-grant-guide/SKILL.md +206 -0
  187. package/skills/research/funding/open-science-guide/SKILL.md +255 -0
  188. package/skills/research/funding/zenodo-api/SKILL.md +174 -0
  189. package/skills/research/methodology/action-research-guide/SKILL.md +201 -0
  190. package/skills/research/methodology/experimental-design-guide/SKILL.md +236 -0
  191. package/skills/research/methodology/grad-school-guide/SKILL.md +182 -0
  192. package/skills/research/methodology/grounded-theory-guide/SKILL.md +171 -0
  193. package/skills/research/methodology/mixed-methods-guide/SKILL.md +208 -0
  194. package/skills/research/methodology/qualitative-research-guide/SKILL.md +234 -0
  195. package/skills/research/methodology/scientify-idea-generation/SKILL.md +222 -0
  196. package/skills/research/paper-review/paper-reading-assistant/SKILL.md +266 -0
  197. package/skills/research/paper-review/peer-review-guide/SKILL.md +227 -0
  198. package/skills/research/paper-review/rebuttal-writing-guide/SKILL.md +185 -0
  199. package/skills/research/paper-review/scientify-write-review-paper/SKILL.md +209 -0
  200. package/skills/tools/code-exec/jupyter-notebook-guide/SKILL.md +178 -0
  201. package/skills/tools/code-exec/python-reproducibility-guide/SKILL.md +341 -0
  202. package/skills/tools/code-exec/r-reproducibility-guide/SKILL.md +236 -0
  203. package/skills/tools/code-exec/sandbox-execution-guide/SKILL.md +221 -0
  204. package/skills/tools/diagram/mermaid-diagram-guide/SKILL.md +269 -0
  205. package/skills/tools/diagram/plantuml-guide/SKILL.md +397 -0
  206. package/skills/tools/diagram/scientific-illustration-guide/SKILL.md +225 -0
  207. package/skills/tools/document/anystyle-api/SKILL.md +199 -0
  208. package/skills/tools/document/grobid-pdf-parsing/SKILL.md +294 -0
  209. package/skills/tools/document/markdown-academic-guide/SKILL.md +217 -0
  210. package/skills/tools/document/pdf-extraction-guide/SKILL.md +321 -0
  211. package/skills/tools/knowledge-graph/knowledge-graph-construction/SKILL.md +306 -0
  212. package/skills/tools/knowledge-graph/ontology-design-guide/SKILL.md +214 -0
  213. package/skills/tools/knowledge-graph/rag-methodology-guide/SKILL.md +325 -0
  214. package/skills/tools/ocr-translate/formula-recognition-guide/SKILL.md +367 -0
  215. package/skills/tools/ocr-translate/handwriting-recognition-guide/SKILL.md +211 -0
  216. package/skills/tools/ocr-translate/latex-ocr-guide/SKILL.md +204 -0
  217. package/skills/tools/ocr-translate/multilingual-research-guide/SKILL.md +234 -0
  218. package/skills/tools/scraping/academic-web-scraping/SKILL.md +326 -0
  219. package/skills/tools/scraping/api-data-collection-guide/SKILL.md +301 -0
  220. package/skills/tools/scraping/web-scraping-ethics-guide/SKILL.md +250 -0
  221. package/skills/writing/citation/bibtex-management-guide/SKILL.md +246 -0
  222. package/skills/writing/citation/citation-style-guide/SKILL.md +248 -0
  223. package/skills/writing/citation/reference-manager-comparison/SKILL.md +208 -0
  224. package/skills/writing/citation/zotero-api/SKILL.md +188 -0
  225. package/skills/writing/composition/abstract-writing-guide/SKILL.md +188 -0
  226. package/skills/writing/composition/discussion-writing-guide/SKILL.md +194 -0
  227. package/skills/writing/composition/introduction-writing-guide/SKILL.md +194 -0
  228. package/skills/writing/composition/literature-review-writing/SKILL.md +196 -0
  229. package/skills/writing/composition/methods-section-guide/SKILL.md +185 -0
  230. package/skills/writing/composition/response-to-reviewers/SKILL.md +215 -0
  231. package/skills/writing/composition/scientific-writing-guide/SKILL.md +152 -0
  232. package/skills/writing/latex/bibliography-management-guide/SKILL.md +206 -0
  233. package/skills/writing/latex/latex-drawing-guide/SKILL.md +234 -0
  234. package/skills/writing/latex/latex-ecosystem-guide/SKILL.md +240 -0
  235. package/skills/writing/latex/math-typesetting-guide/SKILL.md +231 -0
  236. package/skills/writing/latex/overleaf-collaboration-guide/SKILL.md +211 -0
  237. package/skills/writing/latex/tikz-diagrams-guide/SKILL.md +211 -0
  238. package/skills/writing/polish/academic-translation-guide/SKILL.md +175 -0
  239. package/skills/writing/polish/academic-writing-refiner/SKILL.md +143 -0
  240. package/skills/writing/polish/ai-writing-humanizer/SKILL.md +178 -0
  241. package/skills/writing/polish/grammar-checker-guide/SKILL.md +184 -0
  242. package/skills/writing/polish/plagiarism-detection-guide/SKILL.md +167 -0
  243. package/skills/writing/templates/beamer-presentation-guide/SKILL.md +263 -0
  244. package/skills/writing/templates/conference-paper-template/SKILL.md +219 -0
  245. package/skills/writing/templates/thesis-template-guide/SKILL.md +200 -0
  246. package/skills/writing/templates/thesis-writing-guide/SKILL.md +220 -0
  247. package/src/tools/arxiv.ts +131 -0
  248. package/src/tools/crossref.ts +112 -0
  249. package/src/tools/openalex.ts +174 -0
  250. package/src/tools/pubmed.ts +166 -0
  251. package/src/tools/semantic-scholar.ts +108 -0
  252. package/src/tools/unpaywall.ts +58 -0
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: iv-regression-guide
3
+ description: "Apply instrumental variables, 2SLS, and address endogeneity issues"
4
+ metadata:
5
+ openclaw:
6
+ emoji: "wrench"
7
+ category: "analysis"
8
+ subcategory: "econometrics"
9
+ keywords: ["instrumental variables", "2SLS", "endogeneity", "IV regression", "causal inference", "econometrics"]
10
+ source: "wentor-research-plugins"
11
+ ---
12
+
13
+ # Instrumental Variables Regression Guide
14
+
15
+ A skill for applying instrumental variables (IV) estimation to address endogeneity in regression models. Covers the logic of IV, two-stage least squares (2SLS), instrument validity tests, weak instrument diagnostics, and reporting standards.
16
+
17
+ ## The Endogeneity Problem
18
+
19
+ ### Why OLS Fails
20
+
21
+ ```
22
+ Ordinary Least Squares assumes: E[u | X] = 0
23
+ (Regressors are uncorrelated with the error term)
24
+
25
+ This assumption is violated when:
26
+ - Omitted variable bias: A confound affects both X and Y
27
+ - Simultaneity: X affects Y and Y affects X
28
+ - Measurement error: X is measured with noise
29
+
30
+ Consequence: OLS estimates are biased and inconsistent.
31
+ No amount of data will fix this.
32
+ ```
33
+
34
+ ### The IV Solution
35
+
36
+ An instrumental variable Z satisfies two conditions:
37
+
38
+ ```
39
+ 1. Relevance: Z is correlated with the endogenous regressor X
40
+ Cov(Z, X) != 0
41
+
42
+ 2. Exclusion: Z affects Y ONLY through X (not directly)
43
+ Cov(Z, u) = 0
44
+
45
+ Z --> X --> Y
46
+ Z -/-> Y (no direct path)
47
+ ```
48
+
49
+ ## Two-Stage Least Squares (2SLS)
50
+
51
+ ### How 2SLS Works
52
+
53
+ ```
54
+ Stage 1: Regress the endogenous variable on the instrument(s)
55
+ X = gamma_0 + gamma_1 * Z + controls + v
56
+ Save the fitted values: X_hat
57
+
58
+ Stage 2: Regress the outcome on the fitted values
59
+ Y = beta_0 + beta_1 * X_hat + controls + e
60
+
61
+ The coefficient beta_1 is the IV estimate of the causal effect.
62
+ ```
63
+
64
+ ### Implementation in Python
65
+
66
+ ```python
67
+ from linearmodels.iv import IV2SLS
68
+ import pandas as pd
69
+
70
+
71
+ def run_2sls(data: pd.DataFrame, dependent: str,
72
+ endogenous: str, instruments: list[str],
73
+ controls: list[str] = None) -> dict:
74
+ """
75
+ Run a 2SLS instrumental variables regression.
76
+
77
+ Args:
78
+ data: DataFrame with all variables
79
+ dependent: Name of the dependent variable (Y)
80
+ endogenous: Name of the endogenous regressor (X)
81
+ instruments: List of instrument variable names (Z)
82
+ controls: List of exogenous control variable names
83
+ """
84
+ controls = controls or []
85
+ exog_str = " + ".join(["1"] + controls) if controls else "1"
86
+ endog_str = endogenous
87
+ instr_str = " + ".join(instruments)
88
+
89
+ formula = f"{dependent} ~ {exog_str} + [{endog_str} ~ {instr_str}]"
90
+
91
+ model = IV2SLS.from_formula(formula, data)
92
+ result = model.fit(cov_type="robust")
93
+
94
+ return {
95
+ "coefficients": dict(result.params),
96
+ "std_errors": dict(result.std_errors),
97
+ "p_values": dict(result.pvalues),
98
+ "f_statistic_first_stage": result.first_stage.diagnostics,
99
+ "summary": str(result.summary)
100
+ }
101
+ ```
102
+
103
+ ### Implementation in R
104
+
105
+ ```r
106
+ library(ivreg)
107
+
108
+ # 2SLS estimation
109
+ iv_model <- ivreg(
110
+ log(wage) ~ education + experience | parent_education + experience,
111
+ data = df
112
+ )
113
+
114
+ summary(iv_model, diagnostics = TRUE)
115
+ ```
116
+
117
+ ## Instrument Validity Tests
118
+
119
+ ### First-Stage F-Statistic (Relevance)
120
+
121
+ ```python
122
+ def check_weak_instruments(first_stage_f: float) -> dict:
123
+ """
124
+ Evaluate instrument strength using first-stage F-statistic.
125
+
126
+ Args:
127
+ first_stage_f: F-statistic from the first-stage regression
128
+ """
129
+ return {
130
+ "f_statistic": first_stage_f,
131
+ "rule_of_thumb": (
132
+ "Strong instruments" if first_stage_f > 10
133
+ else "Potentially weak instruments"
134
+ ),
135
+ "interpretation": (
136
+ "Stock & Yogo (2005) suggest F > 10 as a minimum for "
137
+ "one endogenous variable. For more precise thresholds, "
138
+ "consult the Stock-Yogo critical values table based on "
139
+ "the number of instruments and desired maximal bias."
140
+ ),
141
+ "if_weak": [
142
+ "Use LIML (Limited Information Maximum Likelihood) instead of 2SLS",
143
+ "Report Anderson-Rubin confidence intervals (robust to weak IV)",
144
+ "Consider finding stronger instruments",
145
+ "Use the Lee et al. (2022) tF procedure for valid inference"
146
+ ]
147
+ }
148
+ ```
149
+
150
+ ### Overidentification Test (Exclusion Restriction)
151
+
152
+ When you have more instruments than endogenous variables, the Hansen J test (or Sargan test) checks whether the extra instruments are valid:
153
+
154
+ ```
155
+ H0: All instruments are valid (uncorrelated with the error)
156
+ H1: At least one instrument is invalid
157
+
158
+ If p < 0.05: Reject -> at least one instrument may violate exclusion
159
+ If p > 0.05: Fail to reject -> instruments appear valid
160
+ (but this test has low power)
161
+ ```
162
+
163
+ ## Classic IV Examples
164
+
165
+ ### Famous Instruments in Economics
166
+
167
+ ```
168
+ Research Question | Endogenous Var | Instrument
169
+ ---------------------------|---------------|------------------
170
+ Returns to education | Years of school| Quarter of birth (Angrist & Krueger)
171
+ Effect of institutions | Institutions | Settler mortality (Acemoglu et al.)
172
+ Colonial origins of trade | Trade openness | Geography (Frankel & Romer)
173
+ Effect of military service | Veteran status | Draft lottery number (Angrist)
174
+ Price elasticity of demand | Price | Supply shifters (cost, weather)
175
+ ```
176
+
177
+ ## Reporting IV Results
178
+
179
+ ### Required Elements
180
+
181
+ ```
182
+ 1. Justify instrument choice with economic/theoretical reasoning
183
+ 2. Report first-stage regression results:
184
+ - Coefficient of Z on X with standard error
185
+ - First-stage F-statistic
186
+ 3. Report second-stage (2SLS) results:
187
+ - IV coefficient with robust standard errors
188
+ - Compare with OLS estimate (discuss direction of bias)
189
+ 4. Report diagnostic tests:
190
+ - Weak instrument test (F-statistic or Kleibergen-Paap)
191
+ - Overidentification test if applicable (Hansen J)
192
+ - Endogeneity test (Hausman or Durbin-Wu-Hausman)
193
+ 5. Discuss threats to instrument validity
194
+ - Can the exclusion restriction be challenged?
195
+ - Are there plausible alternative channels?
196
+ ```
197
+
198
+ Always present both OLS and IV estimates side by side. The comparison helps readers understand the direction and magnitude of endogeneity bias and assess whether the IV correction is meaningful.
@@ -0,0 +1,274 @@
1
+ ---
2
+ name: panel-data-guide
3
+ description: "Panel data analysis with fixed and random effects models"
4
+ metadata:
5
+ openclaw:
6
+ emoji: "table"
7
+ category: "analysis"
8
+ subcategory: "econometrics"
9
+ keywords: ["panel data", "fixed effects", "random effects", "Stata commands"]
10
+ source: "wentor-research-plugins"
11
+ ---
12
+
13
+ # Panel Data Analysis Guide
14
+
15
+ Estimate and interpret fixed effects, random effects, and dynamic panel models using Stata, R, and Python for longitudinal/panel datasets.
16
+
17
+ ## What Is Panel Data?
18
+
19
+ Panel data (also called longitudinal or cross-sectional time-series data) tracks the same units (individuals, firms, countries) across multiple time periods. This structure enables:
20
+
21
+ - Controlling for unobserved heterogeneity (time-invariant omitted variables)
22
+ - Studying dynamic relationships (how X at time t affects Y at time t+1)
23
+ - Increased statistical power through more observations
24
+
25
+ ### Data Structure
26
+
27
+ ```
28
+ | unit_id | year | gdp_growth | investment | trade_openness |
29
+ |---------|------|-----------|------------|----------------|
30
+ | USA | 2015 | 2.9 | 20.5 | 28.3 |
31
+ | USA | 2016 | 1.7 | 20.1 | 27.1 |
32
+ | USA | 2017 | 2.3 | 20.8 | 27.5 |
33
+ | CHN | 2015 | 6.9 | 43.3 | 39.9 |
34
+ | CHN | 2016 | 6.7 | 42.7 | 37.2 |
35
+ | CHN | 2017 | 6.9 | 43.1 | 38.1 |
36
+ ```
37
+
38
+ Key notation:
39
+ - i = unit (cross-sectional dimension): i = 1, ..., N
40
+ - t = time period: t = 1, ..., T
41
+ - Y_it = dependent variable for unit i at time t
42
+
43
+ ## Model Specification
44
+
45
+ ### Pooled OLS
46
+
47
+ ```
48
+ Y_it = alpha + beta * X_it + epsilon_it
49
+ ```
50
+
51
+ Ignores panel structure; assumes no unit-specific effects. Rarely appropriate.
52
+
53
+ ### Fixed Effects (FE) Model
54
+
55
+ ```
56
+ Y_it = alpha_i + beta * X_it + epsilon_it
57
+ ```
58
+
59
+ Each unit has its own intercept (alpha_i) that captures all time-invariant unobserved heterogeneity. The "within" estimator removes alpha_i by demeaning.
60
+
61
+ ### Random Effects (RE) Model
62
+
63
+ ```
64
+ Y_it = alpha + beta * X_it + u_i + epsilon_it
65
+ ```
66
+
67
+ The unit-specific effect u_i is treated as random and uncorrelated with X_it.
68
+
69
+ ## Estimation in Stata
70
+
71
+ ### Setting Up Panel Data
72
+
73
+ ```stata
74
+ * Declare panel structure
75
+ xtset country_id year
76
+
77
+ * Summarize within and between variation
78
+ xtsum gdp_growth investment trade_openness
79
+ ```
80
+
81
+ ### Fixed Effects
82
+
83
+ ```stata
84
+ * Fixed effects regression
85
+ xtreg gdp_growth investment trade_openness, fe
86
+
87
+ * Store results for Hausman test
88
+ estimates store FE
89
+
90
+ * Fixed effects with robust standard errors (clustered by unit)
91
+ xtreg gdp_growth investment trade_openness, fe vce(cluster country_id)
92
+
93
+ * Test joint significance of fixed effects
94
+ testparm i.country_id
95
+ ```
96
+
97
+ ### Random Effects
98
+
99
+ ```stata
100
+ * Random effects regression
101
+ xtreg gdp_growth investment trade_openness, re
102
+
103
+ * Store results for Hausman test
104
+ estimates store RE
105
+ ```
106
+
107
+ ### Hausman Test (FE vs. RE)
108
+
109
+ ```stata
110
+ * Hausman specification test
111
+ hausman FE RE
112
+
113
+ * If p < 0.05: reject RE, use FE
114
+ * If p > 0.05: RE is consistent and efficient, prefer RE
115
+ ```
116
+
117
+ ### First Differences
118
+
119
+ ```stata
120
+ * First-differenced regression (alternative to FE)
121
+ reg D.gdp_growth D.investment D.trade_openness, vce(cluster country_id)
122
+ ```
123
+
124
+ ## Estimation in R (plm Package)
125
+
126
+ ```r
127
+ library(plm)
128
+
129
+ # Convert to panel data frame
130
+ pdata <- pdata.frame(mydata, index = c("country_id", "year"))
131
+
132
+ # Fixed effects
133
+ fe_model <- plm(gdp_growth ~ investment + trade_openness,
134
+ data = pdata, model = "within")
135
+ summary(fe_model)
136
+
137
+ # Random effects
138
+ re_model <- plm(gdp_growth ~ investment + trade_openness,
139
+ data = pdata, model = "random")
140
+ summary(re_model)
141
+
142
+ # Hausman test
143
+ phtest(fe_model, re_model)
144
+
145
+ # Clustered standard errors
146
+ library(lmtest)
147
+ library(sandwich)
148
+ coeftest(fe_model, vcov = vcovHC(fe_model, type = "HC1", cluster = "group"))
149
+
150
+ # Time fixed effects
151
+ fe_twoway <- plm(gdp_growth ~ investment + trade_openness + factor(year),
152
+ data = pdata, model = "within")
153
+
154
+ # Test for time fixed effects
155
+ pFtest(fe_twoway, fe_model)
156
+ ```
157
+
158
+ ## Estimation in Python (linearmodels)
159
+
160
+ ```python
161
+ import pandas as pd
162
+ from linearmodels.panel import PanelOLS, RandomEffects, compare
163
+
164
+ # Set multi-index for panel structure
165
+ data = data.set_index(["country_id", "year"])
166
+
167
+ # Fixed effects
168
+ fe = PanelOLS.from_formula(
169
+ "gdp_growth ~ investment + trade_openness + EntityEffects",
170
+ data=data
171
+ )
172
+ fe_result = fe.fit(cov_type="clustered", cluster_entity=True)
173
+ print(fe_result.summary)
174
+
175
+ # Random effects
176
+ re = RandomEffects.from_formula(
177
+ "gdp_growth ~ investment + trade_openness + 1",
178
+ data=data
179
+ )
180
+ re_result = re.fit()
181
+ print(re_result.summary)
182
+
183
+ # Two-way fixed effects (entity + time)
184
+ twoway = PanelOLS.from_formula(
185
+ "gdp_growth ~ investment + trade_openness + EntityEffects + TimeEffects",
186
+ data=data
187
+ )
188
+ twoway_result = twoway.fit(cov_type="clustered", cluster_entity=True)
189
+ print(twoway_result.summary)
190
+
191
+ # Compare models
192
+ print(compare({"FE": fe_result, "RE": re_result, "Two-way FE": twoway_result}))
193
+ ```
194
+
195
+ ## Diagnostic Tests
196
+
197
+ ### Testing for Panel Effects
198
+
199
+ | Test | Stata | R | Null Hypothesis |
200
+ |------|-------|---|----------------|
201
+ | F-test for FE | Built into `xtreg, fe` | `pFtest()` | All alpha_i = 0 (pooled OLS is appropriate) |
202
+ | Breusch-Pagan LM | `xttest0` | `plmtest()` | Var(u_i) = 0 (pooled OLS vs. RE) |
203
+ | Hausman | `hausman FE RE` | `phtest()` | RE is consistent (u_i uncorrelated with X) |
204
+
205
+ ### Testing for Serial Correlation
206
+
207
+ ```stata
208
+ * Wooldridge test for serial correlation in panel data
209
+ xtserial gdp_growth investment trade_openness
210
+ * If p < 0.05: serial correlation present; use clustered SE or AR(1) correction
211
+ ```
212
+
213
+ ```r
214
+ # Wooldridge test
215
+ pbgtest(fe_model) # Breusch-Godfrey test for serial correlation
216
+ ```
217
+
218
+ ### Testing for Heteroskedasticity
219
+
220
+ ```stata
221
+ * Modified Wald test for groupwise heteroskedasticity
222
+ xttest3
223
+ * If p < 0.05: heteroskedasticity present; use robust/clustered SE
224
+ ```
225
+
226
+ ## Advanced Panel Models
227
+
228
+ ### Dynamic Panel (Arellano-Bond GMM)
229
+
230
+ When a lagged dependent variable is included as a regressor:
231
+
232
+ ```stata
233
+ * Arellano-Bond one-step GMM
234
+ xtabond gdp_growth investment trade_openness, lags(1) vce(robust)
235
+
236
+ * System GMM (Blundell-Bond) - more efficient
237
+ xtdpdsys gdp_growth investment trade_openness, lags(1) vce(robust)
238
+
239
+ * Sargan/Hansen test for overidentifying restrictions
240
+ * AR(2) test for second-order serial correlation
241
+ ```
242
+
243
+ ### Difference-in-Differences (DID)
244
+
245
+ ```stata
246
+ * Basic DID with two-way fixed effects
247
+ xtreg outcome treated##post, fe vce(cluster unit_id)
248
+
249
+ * Event study specification
250
+ xtreg outcome i.relative_time##treated, fe vce(cluster unit_id)
251
+ ```
252
+
253
+ ## Reporting Results
254
+
255
+ ```
256
+ Table X: Panel Regression Results (Fixed Effects)
257
+ Dependent Variable: GDP Growth (%)
258
+
259
+ (1) (2) (3)
260
+ FE RE Two-way FE
261
+ Investment 0.125*** 0.118*** 0.131***
262
+ (0.032) (0.029) (0.035)
263
+ Trade Openness 0.045** 0.051** 0.038*
264
+ (0.018) (0.017) (0.020)
265
+
266
+ Entity FE Yes No Yes
267
+ Time FE No No Yes
268
+ Observations 850 850 850
269
+ R-squared (within) 0.234 0.228 0.267
270
+ Hausman test (p) -- 0.003 --
271
+
272
+ Notes: Robust standard errors clustered at the country level in
273
+ parentheses. * p<0.10, ** p<0.05, *** p<0.01.
274
+ ```
@@ -0,0 +1,250 @@
1
+ ---
2
+ name: robustness-checks
3
+ description: "Sequential robustness checks in Stata with confounder blocks"
4
+ metadata:
5
+ openclaw:
6
+ emoji: "🔬"
7
+ category: "analysis"
8
+ subcategory: "econometrics"
9
+ keywords: ["robustness checks", "sensitivity analysis", "Stata regression", "panel data", "causal inference", "fixed effects"]
10
+ source: "https://github.com/awesome-econ-ai/academic-skills"
11
+ ---
12
+
13
+ # Robustness Checks
14
+
15
+ A skill for conducting sequential robustness checks in Stata, systematically adding blocks of potential confounders to assess estimate stability.
16
+
17
+ ## Quick Start
18
+
19
+ ```stata
20
+ * Base model
21
+ svy: regress outcome controls treatment
22
+ estimates store m1
23
+
24
+ * Add confounder block
25
+ svy: regress outcome controls treatment confounder1 confounder2
26
+ estimates store m2
27
+
28
+ * Compare
29
+ esttab m1 m2, se star(+ 0.1 * 0.05 ** 0.01)
30
+ ```
31
+
32
+ ## Key Patterns
33
+
34
+ ### 1. Sequential Model Building
35
+
36
+ ```stata
37
+ * Define base controls
38
+ local control_var i.batch age i.race i.gender i.education
39
+ estimates clear
40
+
41
+ * Model 1: Base model
42
+ svy: regress outcome `control_var' treatment
43
+ margins, dydx(treatment) post
44
+ estimates store m1
45
+
46
+ * Model 2: Add contextual factors
47
+ svy: regress outcome `control_var' treatment covid health_insurance
48
+ margins, dydx(treatment) post
49
+ estimates store m2
50
+
51
+ * Model 3: Add health factors
52
+ svy: regress outcome `control_var' treatment cci_charlson any_encounter
53
+ margins, dydx(treatment) post
54
+ estimates store m3
55
+
56
+ * Model 4: Add psychological factors
57
+ svy: regress outcome `control_var' treatment depression anxiety
58
+ margins, dydx(treatment) post
59
+ estimates store m4
60
+
61
+ * Model 5: Add behavioral factors
62
+ svy: regress outcome `control_var' treatment i.smoke_status bmi
63
+ margins, dydx(treatment) post
64
+ estimates store m5
65
+ ```
66
+
67
+ ### 2. Standard Robustness Check Template
68
+
69
+ ```stata
70
+ *------------------------------------------------------------
71
+ * Table: Robustness Checks
72
+ *------------------------------------------------------------
73
+ version 17
74
+ clear all
75
+ use "analysis_data.dta", clear
76
+ svyset cluster [pweight = weight]
77
+
78
+ * Base controls (always included)
79
+ local control_var i.batch leukocytes age i.race i.gender i.education i.marital
80
+ estimates clear
81
+
82
+ *--- Model 1: Baseline ---
83
+ svy: regress outcome `control_var' treatment
84
+ margins, dydx(treatment) post
85
+ estimates store m1
86
+
87
+ *--- Model 2: + COVID & Insurance ---
88
+ svy: regress outcome `control_var' treatment covid health_insurance
89
+ margins, dydx(treatment) post
90
+ estimates store m2
91
+
92
+ *--- Model 3: + Healthcare utilization ---
93
+ svy: regress outcome `control_var' treatment cci_charlson any_encounter_3years
94
+ margins, dydx(treatment) post
95
+ estimates store m3
96
+
97
+ *--- Model 4: + Multimorbidity ---
98
+ svy: regress outcome `control_var' treatment multi_morbidity
99
+ margins, dydx(treatment) post
100
+ estimates store m4
101
+
102
+ *--- Model 5: + Psychosocial factors ---
103
+ svy: regress outcome `control_var' treatment matter_important matter_depend
104
+ margins, dydx(treatment) post
105
+ estimates store m5
106
+
107
+ *--- Model 6: + Occupation ---
108
+ svy: regress outcome `control_var' treatment i.occ_group
109
+ margins, dydx(treatment) post
110
+ estimates store m6
111
+
112
+ *--- Model 7: + Smoking ---
113
+ svy: regress outcome `control_var' treatment i.smoke_status
114
+ margins, dydx(treatment) post
115
+ estimates store m7
116
+
117
+ *--- Model 8: + Childhood adversity ---
118
+ svy: regress outcome `control_var' treatment c.aces_sum_std
119
+ margins, dydx(treatment) post
120
+ estimates store m8
121
+
122
+ *--- Export ---
123
+ esttab m1 m2 m3 m4 m5 m6 m7 m8 using "robustness.csv", csv se ///
124
+ mtitle("Base" "+COVID" "+Health" "+Morbid" "+Psych" "+Occ" "+Smoke" "+ACE") ///
125
+ nogap label replace star(+ 0.1 * 0.05 ** 0.01)
126
+ ```
127
+
128
+ ### 3. Multiple Outcomes
129
+
130
+ ```stata
131
+ * Repeat for each outcome
132
+ foreach outcome in pace grimage2 phenoage {
133
+ estimates clear
134
+
135
+ svy: regress `outcome' `control_var' treatment
136
+ margins, dydx(treatment) post
137
+ estimates store `outcome'_m1
138
+
139
+ svy: regress `outcome' `control_var' treatment covid health_insurance
140
+ margins, dydx(treatment) post
141
+ estimates store `outcome'_m2
142
+
143
+ svy: regress `outcome' `control_var' treatment cci_charlson any_encounter
144
+ margins, dydx(treatment) post
145
+ estimates store `outcome'_m3
146
+ }
147
+
148
+ * Export all
149
+ esttab pace_m1 pace_m2 pace_m3 grimage2_m1 grimage2_m2 grimage2_m3 ///
150
+ using "robustness_all.csv", csv se nogap label replace
151
+ ```
152
+
153
+ ### 4. Model Specification Checks
154
+
155
+ ```stata
156
+ estimates clear
157
+
158
+ * Linear specification
159
+ svy: regress outcome `control_var' treatment
160
+ estimates store linear
161
+
162
+ * Logged outcome
163
+ gen log_outcome = ln(outcome + 1)
164
+ svy: regress log_outcome `control_var' treatment
165
+ estimates store log_linear
166
+
167
+ * Categorical treatment
168
+ svy: regress outcome `control_var' i.treatment_cat
169
+ estimates store categorical
170
+
171
+ * With squared term
172
+ svy: regress outcome `control_var' c.treatment##c.treatment
173
+ estimates store quadratic
174
+
175
+ esttab linear log_linear categorical quadratic using "spec_checks.csv", ///
176
+ csv se nogap label replace
177
+ ```
178
+
179
+ ### 5. Sample Restriction Checks
180
+
181
+ ```stata
182
+ estimates clear
183
+
184
+ * Full sample
185
+ svy: regress outcome `control_var' treatment
186
+ estimates store full
187
+
188
+ * Exclude outliers
189
+ svy: regress outcome `control_var' treatment if outcome < p99_outcome
190
+ estimates store no_outliers
191
+
192
+ * Complete cases only
193
+ svy: regress outcome `control_var' treatment if complete_case == 1
194
+ estimates store complete
195
+
196
+ * Subpopulation
197
+ svy, subpop(if age >= 50): regress outcome `control_var' treatment
198
+ estimates store age50plus
199
+
200
+ esttab full no_outliers complete age50plus using "sample_checks.csv", ///
201
+ csv se nogap label replace
202
+ ```
203
+
204
+ ### 6. Alternative Variable Definitions
205
+
206
+ ```stata
207
+ estimates clear
208
+
209
+ * Binary treatment
210
+ svy: regress outcome `control_var' treatment_binary
211
+ margins, dydx(treatment_binary) post
212
+ estimates store binary
213
+
214
+ * Continuous treatment
215
+ svy: regress outcome `control_var' treatment_continuous
216
+ margins, dydx(treatment_continuous) post
217
+ estimates store continuous
218
+
219
+ * Categorical treatment
220
+ svy: regress outcome `control_var' i.treatment_cat
221
+ margins, dydx(treatment_cat) post
222
+ estimates store categorical
223
+
224
+ * Standardized treatment
225
+ svy: regress outcome `control_var' c.treatment_std
226
+ margins, dydx(treatment_std) post
227
+ estimates store standardized
228
+
229
+ esttab binary continuous categorical standardized using "alt_definitions.csv", ///
230
+ csv se nogap label replace
231
+ ```
232
+
233
+ ## Interpretation Guide
234
+
235
+ | Result | Interpretation |
236
+ |--------|----------------|
237
+ | Estimate stable across models | Robust to confounding |
238
+ | Estimate attenuates with additions | Confounding present |
239
+ | Estimate reverses sign | Serious confounding concern |
240
+ | Estimate strengthens | Suppression effect |
241
+ | SE increases substantially | Multicollinearity |
242
+
243
+ ## Tips
244
+
245
+ - Start with theoretically-motivated confounder blocks
246
+ - Order blocks from most to least plausible confounders
247
+ - Document the rationale for each block
248
+ - Present all models, not just the "best" one
249
+ - Watch for substantial increases in standard errors (multicollinearity)
250
+ - Consider pre-registering the robustness check plan