/ai-analyst-plus:causalfrom ai-analyst-plus
Estimates treatment effects from observational data when experiments aren't possible. Supports difference-in-differences, propensity score matching, pre-post analysis, and regression adjustment with assumption checks and sensitivity analysis.
Ships in ai-analyst-plus. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
If the skill install path cannot be resolved (some sandboxed environments): read the script file(s) from this skill, write a copy into a scripts/ folder inside the working folder, and run from there. The scripts are self-contained.
Multi-mode skill for causal inference when experiments aren't possible. Helps users estimate treatment effects from observational data with explicit assumption checking, sensitivity analysis, and mandatory caveats. Uses the coded estimator library bundled in this skill at scripts/causal_stats/.
Using the bundled library: add this skill's scripts/ directory to sys.path, then import, e.g.
import sys
sys.path.insert(0, "<path to this skill>/scripts") # the scripts/ dir next to this SKILL.md
from causal_stats import did_basic
Requires pandas, numpy, scipy, statsmodels, and scikit-learn (for propensity matching); install the last two in the sandbox if missing.
Invoke as /causal [mode] or trigger on causal inference intents:
/causal selectPurpose: Walk the method selection decision tree and recommend a causal method.
Agent: the causal-method-selector plugin agent
Flow:
/experiment design/causal analyzePurpose: Run the selected causal method on data.
Agent: the causal-analyzer plugin agent
Flow:
from causal_stats import (
pre_post_analysis, did_basic, propensity_match,
regression_adjust,
)
# Method routing:
# "pre_post" → pre_post_analysis(pre, post, covariates)
# "did" → did_basic(df, outcome, treat, post)
# "psm" → propensity_match(df, treat, covariates, outcome)
# "regression" → regression_adjust(df, outcome, treatment, covariates)
working/causal_analysis_results.json/causal checkPurpose: Run assumption checks for the selected method.
Agent: the causal-assumption-checker plugin agent
Flow:
from causal_stats import (
check_parallel_trends, check_common_support,
balance_table,
)
/causal sensitivityPurpose: Test how robust the estimate is to unmeasured confounding.
Agent: the causal-sensitivity plugin agent
Flow:
from causal_stats import rosenbaum_bounds, e_value
# PSM: rosenbaum_bounds(treated_outcomes, control_outcomes)
# All: e_value(risk_ratio, ci_lower)
/causal reportPurpose: Generate a report with mandatory caveats.
Agent: the causal-report-generator plugin agent
Flow:
reports/causal_report_{{DATE}}.md/causal fullPurpose: End-to-end: select → analyze → check → sensitivity → report. Flow: Runs all modes in sequence. All Type C checkpoints fire.
Methods ranked by causal credibility (highest to lowest):
| Level | Method | Confidence |
|---|---|---|
| 1 | RCT (Randomized Experiment) | HIGH |
| 2 | DiD + Regression Adjustment | MODERATE-HIGH |
| 3 | PSM (Good Overlap + Balance) | MODERATE |
| 4 | DiD (Parallel Trends OK) | MODERATE |
| 5 | Regression Adjustment | LOW-MODERATE |
| 6 | Pre-Post (With Trend) | LOW |
| 7 | Pre-Post (Simple) | VERY LOW |
Every causal report MUST include the method-specific caveat. These are architecturally required — the agent cannot produce a report without them.
| Method | Mandatory Caveat |
|---|---|
| Pre-Post | "Assumes nothing else changed during this period. Any concurrent event could explain this result." |
| DiD | "Assumes the control group would have followed the same trend. Plausible but unprovable." |
| PSM | "Controls for observed confounders only. Unmeasured factors could bias this estimate." |
| Regression | "Assumes all relevant confounders are included and the model is correctly specified." |
| Function | Module | Use For |
|---|---|---|
pre_post_analysis() | causal_stats.pre_post | Pre-post comparison |
did_basic() | causal_stats.did | 2x2 DiD estimator |
parallel_trends_test() | causal_stats.did | Test parallel trends assumption |
event_study() | causal_stats.did | Period-by-period effects |
propensity_match() | causal_stats.matching | PSM pipeline |
balance_table() | causal_stats.balance | SMD balance diagnostics |
love_plot() | causal_stats.balance | Before/after balance visual |
regression_adjust() | causal_stats.regression | OLS with covariates |
rosenbaum_bounds() | causal_stats.sensitivity | PSM sensitivity |
e_value() | causal_stats.sensitivity | Universal sensitivity measure |
check_parallel_trends() | causal_stats.assumptions | DiD assumption |
check_common_support() | causal_stats.assumptions | PSM assumption |
/causal select → "Can you randomize? YES" → suggest /experiment design/experiment power → NOT_VIABLE → suggest /causal select/causal check → All assumptions FAIL → suggest redesign or descriptive-only analysisanalyses/{slug}/
├── causal_config.yaml # Method selection + parameters (tracked)
├── working/ # Intermediates (gitignored)
│ ├── causal_analysis_results.json
│ ├── assumption_report.md
│ └── sensitivity_report.md
└── reports/ # Final reports (tracked)
└── causal_report_{{DATE}}.md
scripts/causal_stats/__init__.py (opens in a new tab)scripts/causal_stats/assumptions.py (opens in a new tab)scripts/causal_stats/balance.py (opens in a new tab)scripts/causal_stats/did.py (opens in a new tab)scripts/causal_stats/matching.py (opens in a new tab)scripts/causal_stats/pre_post.py (opens in a new tab)scripts/causal_stats/regression.py (opens in a new tab)scripts/causal_stats/sensitivity.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ai-analyst-lab/ai-analyst-plugin --plugin ai-analyst-plus47 skills in this plugin
/always-compareNever present a metric or number in isolation; anchor every number to a comparison (prior period, benchmark, or another segment) or state that none is available. Use every time you show a number: rates, counts, revenue, averages, query results, chart labels, summary stats. Trigger on output containing "the rate is", "we saw", "total", "average", "conversion", "revenue", "users", "sessions", "churn", "AOV", "NPS", or any figure pulled from data./analysis-designTurn a vague hunch or stakeholder request into a rigorous analysis plan via a staged pipeline (hypothesis sharpening, confound scan, V1, feedback, V2 redesign). Trigger on "I think X caused Y", "design an analysis for", "what's driving", "V2 after feedback", "stakeholder comments", "redesign the analysis". Vs question-framing (the lightweight framing gate before every analysis): use THIS only for a real hunch, confound scan, or V1 to V2 redesign./analyst-coreOperating rules for every data analysis. Apply for ANY data-analysis intent: "analyze", "investigate", "why did X change", "compare", "report on", "dashboard", "metrics", "funnel", "retention", "revenue", "conversion", "trend", "segment", "forecast", "how are we doing", "dig into", "break down", or any question about data, a metric, a CSV, or a table. Sets the method and routes to the other skills; load before any analytical question.Other plugins' skills for the same job