Python Causality Guide logo

Python Causality Guide

Community
wentorai
python-causality-guide

Learn causal inference with Python using the Brave and True handbook

Overview

Publisherwentorai
Repositoryresearch-plugins
Skill namepython-causality-guide
Stars
294
Forks
42
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by wentorai on GitHub. Read the source before you install it.

Installation

Install the Python Causality Guide AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wentorai/research-plugins.git /tmp/research-plugins
mkdir -p .claude/skills
cp -r /tmp/research-plugins/skills/analysis/econometrics/python-causality-guide .claude/skills/python-causality-guide
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Python Causality Guide in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Python Causality Guide on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Python Causality Guide is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Causal Inference for the Brave and True

Overview

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.

Installation and Setup

The handbook runs as Jupyter notebooks. Set up the environment:

bash
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:

bash
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.

Core Methods Covered

Potential Outcomes Framework: The book begins by establishing the Neyman-Rubin potential outcomes model, defining treatment effects and the fundamental problem of causal inference:

python
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:

python
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:

python
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:

python
# 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.

Research Workflow Integration

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:

  • Randomized experiment available: simple comparison of means or regression adjustment
  • Selection on observables: matching, propensity scores, or regression
  • Unobserved confounders with instrument: instrumental variables
  • Policy threshold: regression discontinuity
  • Before/after with control group: difference-in-differences
  • Single treated unit over time: synthetic control

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.

Best Practices Highlighted in the Handbook

  1. Always graph your data first: Visual inspection reveals patterns that inform modeling choices and expose violations of identifying assumptions.
  2. Understand your identification strategy: Before running any estimator, articulate clearly what variation identifies the causal effect and what assumptions are required.
  3. Cluster standard errors appropriately: When treatment is assigned at group level, cluster standard errors at that level to avoid overstating statistical significance.
  4. Run robustness checks: Vary specifications, bandwidths, control variables, and functional forms to assess sensitivity of conclusions.
  5. Report effect sizes alongside p-values: Statistical significance without practical significance is not informative for policy or scientific understanding.

References

Frequently asked questions

What does the Python Causality Guide AI skill do?

Learn causal inference with Python using the Brave and True handbook

Why use Python Causality Guide on TypingMind?

Because you install it once and use it with any model. Python Causality Guide is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Python Causality Guide in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wentorai/research-plugins/tree/main/skills/analysis/econometrics/python-causality-guide. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Python Causality Guide?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Python Causality Guide?

As many as you like. As long as a model supports skills, you can use Python Causality Guide with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Python Causality Guide AI skill free?

Yes. It is published on GitHub by wentorai under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇