python-causality-guide
Learn causal inference with Python using the Brave and True handbook
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Learn causal inference with Python using the Brave and True handbook
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Route empirical-research requests through the Auto-Empirical Research Skills catalog when this whole repository is installed as one skill in Codex, CodeBuddy, Claude Code, or another IDE. Use to choose and load the right vendored AERS skill for causal inference, econometrics, replication, data acquisition, manuscript writing, peer review and referee responses, citation checking, de-AIGC editing, or full empirical-paper workflows without reading the entire repository at once.
公司金融实证研究的"漏斗式选题查找器"。互动开场先后询问 (1) 研究方向、(2) 候选标题数量 N, 再扫描全球文献(已出版英文学术期刊 + SSRN working paper + 全球高校 department seminar 1 年内日程),基于 Edmans (2024) "1000 Rejections" 红线生成 N 个候选标题,**通过并行 subagent(Agent 工具)批量生成计划书 + 查新;每个 subagent 必须强制调用 Skill 工具加载 econfin-proposal 与 novelty-check 两个预设 skill 完成各自模块**,**只有当 novelty score >= 9 时(即 JF/JFE/RFS 顶刊层次),subagent 才把 proposal + 查新报告合并的 md 写入 F:\Dropbox\CC\选题大全\<研究方向短名>\(以"简短选题名称-分数"命名,子文件夹名由 Step 0 从用户输入的研究方向派生);< 9 分的选题在 subagent 内部直接丢弃,绝不写盘、绝不输出**。当用户说"找选题"、"帮我找选题"、"想做 X 方向"、 "empirical CF idea search"、"批量生成研究计划书"、"100 ideas"、"econfin-idea-finder" 时触发。
Create and compile beautiful Beamer presentations following the Rhetoric of Decks philosophy. Use when making slides, creating decks, or compiling .tex presentation files.
Scaffold a new research project with standard directory structure, CLAUDE.md template, and documented README. Use this at the start of every new project to ensure consistent organization.
Download, split, and deeply read academic PDFs. Use when asked to read, review, or summarize an academic paper. Splits PDFs into 4-page chunks, reads them in small batches, and produces structured reading notes — avoiding context window crashes and shallow comprehension.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
| name | python-causality-guide |
| description | Learn causal inference with Python using the Brave and True handbook |
| metadata | {"openclaw":{"emoji":"📊","category":"analysis","subcategory":"econometrics","keywords":["causal-inference","python","econometrics","statistics","treatment-effects","observational-studies"],"source":"https://github.com/matheusfacure/python-causality-handbook"}} |
Causal Inference for the Brave and True is an open-source, Python-based textbook by Matheus Facure that teaches causal inference methods through practical implementations. The book bridges the gap between theoretical econometrics textbooks and hands-on data science practice, presenting each method with runnable Python code, real-world datasets, and intuitive explanations that demystify the mathematics behind causal reasoning.
The handbook covers the full spectrum of causal inference techniques used in modern empirical research, from foundational concepts like potential outcomes and directed acyclic graphs (DAGs) through advanced methods including instrumental variables, regression discontinuity, difference-in-differences, and synthetic control. Each chapter builds on the previous one, constructing a coherent framework for thinking about causation from observational data.
With over 3,000 GitHub stars, this resource has become a standard reference for graduate students, applied researchers, and data scientists seeking to add causal reasoning to their analytical toolkit. The emphasis on Python implementation makes it directly applicable to modern research workflows.
The handbook runs as Jupyter notebooks. Set up the environment:
git clone https://github.com/matheusfacure/python-causality-handbook.git
cd python-causality-handbook
# Create a virtual environment
python -m venv causal-env
source causal-env/bin/activate
# Install dependencies
pip install numpy pandas matplotlib seaborn scikit-learn statsmodels
pip install linearmodels causalinference
pip install jupyter
Launch the notebook server:
jupyter notebook
The chapters are organized as numbered Jupyter notebooks, starting from foundational concepts and progressing to advanced methods. Each notebook is self-contained with all data loading and analysis code included.
Potential Outcomes Framework: The book begins by establishing the Neyman-Rubin potential outcomes model, defining treatment effects and the fundamental problem of causal inference:
import pandas as pd
import numpy as np
from scipy.stats import ttest_ind
# Estimate ATE from randomized experiment
treated = data[data["treatment"] == 1]["outcome"]
control = data[data["treatment"] == 0]["outcome"]
ate = treated.mean() - control.mean()
t_stat, p_value = ttest_ind(treated, control)
print(f"ATE: {ate:.3f}, p-value: {p_value:.4f}")
Regression and Matching: OLS regression for causal estimation, understanding omitted variable bias, propensity score methods, and matching estimators:
import statsmodels.formula.api as smf
# OLS with controls
model = smf.ols("outcome ~ treatment + age + income + education", data=data)
results = model.fit(cov_type="HC1")
print(results.summary().tables[1])
Instrumental Variables: Two-stage least squares and the local average treatment effect, with practical guidance on instrument validity and weak instrument diagnostics:
from linearmodels.iv import IV2SLS
# Two-stage least squares
iv_formula = "outcome ~ 1 + [treatment ~ instrument]"
iv_model = IV2SLS.from_formula(iv_formula, data=data)
iv_results = iv_model.fit(cov_type="robust")
print(iv_results.summary)
Difference-in-Differences: Parallel trends assumption, two-way fixed effects, event study designs, and staggered treatment adoption:
# Difference-in-Differences with two-way fixed effects
did_model = smf.ols(
"outcome ~ treated_post + C(unit_id) + C(time_period)",
data=panel_data
)
did_results = did_model.fit(cov_type="cluster", cov_kwds={"groups": panel_data["unit_id"]})
Regression Discontinuity: Sharp and fuzzy RD designs, bandwidth selection, and local polynomial estimation for identifying causal effects at policy thresholds.
Synthetic Control: Constructing counterfactual units from donor pools for comparative case studies, with inference via placebo tests.
Graduate Coursework: The handbook maps directly to applied econometrics and causal inference course syllabi. Students can follow along with lectures by running the corresponding notebooks, experimenting with parameter changes, and observing how different assumptions affect estimates.
Method Selection Guide: Use the decision framework presented across chapters to choose the appropriate method for your research question:
Replication and Extension: Each chapter uses real or realistic datasets. Researchers can adapt the code to their own data by replacing data loading steps while preserving the analytical pipeline.
Teaching Tool: Instructors can assign chapters as interactive homework, asking students to modify assumptions, change specifications, or apply methods to new datasets. The notebook format makes it straightforward to create assignments with embedded solutions.