effect-estimation
Operate DoWhy CausalModel potential-outcomes workflows for identification, estimation, do-operations, refutation, and sensitivity analysis.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- effect-estimation
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate DoWhy CausalModel potential-outcomes workflows for identification, estimation, do-operations, refutation, and sensitivity analysis.
- disable-model-invocation
- true
02 资源文件 7
- 参考文档references/api-reference.md11.5 KB
- 参考文档references/econml-cate.md10.1 KB
- 参考文档references/estimators-and-refuters.md14.1 KB
- 参考文档references/troubleshooting.md11.0 KB
- 参考文档references/workflows.md14.8 KB
- 脚本scripts/parallel_refutation_template.py8.4 KB
- 脚本scripts/smoke_causal_model.py5.9 KB
03 SKILL.md 正文
Effect Estimation
Use this sub-skill when the user wants DoWhy's classic potential-outcomes
workflow around CausalModel: model assumptions, identify an estimand, estimate
ACE/CATE/frontdoor/IV/mediation effects, compute do, or refute an effect
estimate.
This file is a router. Read the bundled references for concrete APIs, parameters, recipes, and failure recovery before writing nontrivial code.
Route here
Route here for requests mentioning any of these signals:
CausalModel,identify_effect,estimate_effect,refute_estimate, orCausalModel.do.- estimate causal effect, average causal effect, ATE, ACE, ATT, ATC, CATE, conditional effect, heterogeneous effect, or effect modifiers.
- backdoor adjustment, maximal adjustment, minimal adjustment, efficient adjustment, ID algorithm, instrumental variable, frontdoor, mediation, natural direct effect, or natural indirect effect.
- method names such as
backdoor.linear_regression,backdoor.propensity_score_matching,iv.instrumental_variable,frontdoor.two_stage_regression, ormediation.two_stage_regression. - propensity score matching, stratification, weighting, distance matching, linear regression, generalized linear model, doubly robust estimator, regression discontinuity, or TabPFN estimator in DoWhy.
- EconML or CausalML estimator calls through DoWhy's
estimate_effectAPI. - robustness checks: random common cause, placebo treatment, data subset, bootstrap, dummy outcome, unobserved common cause, E-value, partial R2, or sensitivity analysis.
- errors about missing
method_name, no valid identified estimand, no instruments, unidentifiable effects, estimate absent before refutation, NaNs, or graph/data variable mismatches in the classic workflow.
Route away
dowhy.gcmgraphical causal models, structural mechanisms, GCM sampling, GCM interventions, point counterfactuals, anomaly/root-cause attribution, distribution change, and GCM graph/model validation belong in ../graphical-causal-models/SKILL.md.- pandas
df.causal.do, do-samplers, graph string parsing, graph plotting, data/schema preparation, built-in datasets, data transformers, graph discovery handoff, and time-series helper questions belong in ../data-graph-interfaces/SKILL.md. - Package installation, Python version compatibility, optional dependency overview, and import-environment checks belong in the root DoWhy references.
Read first
- references/api-reference.md records verified
CausalModel, identification, estimation,do, refutation, and result-object signatures and return types. - references/workflows.md gives model-identify-
estimate-refute recipes, graph/common-causes/instrument inputs, conditional
effects, estimator reuse,
do, and validation steps. - references/estimators-and-refuters.md maps estimator/refuter method-name grammar to built-in choices, important parameters, sensitivity options, and native behavior anchors.
- references/econml-cate.md explains optional
EconML, CausalML, and TabPFN boundaries,
method_paramsshapes, and dependency or access caveats. - references/troubleshooting.md lists common symptoms, likely causes, recovery steps, and stop conditions for classic effect-estimation failures.
- scripts/smoke_causal_model.py is a tiny
no-download ATE smoke script with
--samples,--seed, and--tolerance. - scripts/parallel_refutation_template.py is an importable helper and CLI template for small parallel refuter runs on synthetic or user-provided CSV data.
First decision
- Decide whether the user already has a causal graph, role lists
(
common_causes,instruments,effect_modifiers), or neither. - If graph formats, plotting, pandas accessor sampling, or temporal schemas are
the main problem, route to
data-graph-interfacesbefore estimating. - Decide the estimand: total ATE, ATT/ATC, conditional effect, IV effect,
frontdoor effect, natural direct effect, natural indirect effect, or a
do(x)outcome expectation. - Identify before estimating. Do not choose an estimator only by convenience; the estimator prefix must match an identified strategy.
- Refute only after a valid
CausalEstimateexists.
Core protocol
- Construct
CausalModel(data=df, treatment=..., outcome=..., graph=...)when the user has a DAG; otherwise use explicitcommon_causes,instruments, andeffect_modifiersrole lists. - Ensure treatment, outcome, adjustment, instrument, mediator, and effect modifier names match DataFrame columns exactly unless a variable is intended to be unobserved in the graph.
- Call
identified_estimand = model.identify_effect(...)and inspect the printed estimand or its variable lists before callingestimate_effect. - Always provide
method_nametoestimate_effect,do, andrefute_estimate;Noneis an error by design. - Use method names in
<identifier>.<estimator>form, for examplebackdoor.linear_regression,iv.instrumental_variable, orfrontdoor.two_stage_regression. - Use
target_units="ate","att","atc", a row-filter lambda, or an effect- modifier DataFrame only when the selected estimator supports that form. - Use
fit_estimator=Falseonly after the same model has cached a fitted estimator for the exact same method name and compatible effect modifiers. - For
CausalModel.do, choose a regression-style estimator that implements the do-operator, such asbackdoor.linear_regression; many estimators do not. - Pass method-specific estimator settings in
method_params; use nestedfit_paramsonly for options that belong to the estimator'sfitcall. - Set explicit seeds and low simulation counts for smoke refuters; increase
num_simulationsonly for final analysis. - Treat refuters as robustness diagnostics, not proof. A refuter failure means revisit graph, data quality, estimand, estimator, or domain assumptions.
Estimator choice shortcuts
- Start with
backdoor.linear_regressionfor a small, transparent baseline when linear outcome assumptions are acceptable. - Use propensity score matching, stratification, or weighting for binary treatment with observed backdoor variables and adequate overlap.
- Use
backdoor.generalized_linear_modelfor GLM outcome models; provide astatsmodelsfamily inmethod_params. - Use
iv.instrumental_variableonly when valid instruments are identified and there are at least as many instruments as treatment variables. - Use
iv.regression_discontinuitywhen an instrument-like threshold variable, threshold value, and bandwidth are part of the design. - Use
frontdoor.two_stage_regressionfor a singleton frontdoor mediator, andmediation.two_stage_regressionfor NDE/NIE mediation estimands. - Use optional EconML, CausalML, or TabPFN estimators only when the relevant package, model access, and compute constraints have been verified.
Refutation shortcuts
- Use
random_common_causeto test invariance to an independent added covariate. - Use
placebo_treatment_refuterto test that a randomized or permuted treatment gives an effect near zero. - Use
data_subset_refuterto test stability under random subsampling. - Use
bootstrap_refuterto test stability under bootstrap resampling and noise. - Use
dummy_outcome_refuterwhen the outcome should be replaced by a known synthetic target. - Use
add_unobserved_common_causefor sensitivity analysis; choosedirect-simulation,linear-partial-R2,non-parametric-partial-R2, ore-valueaccording to estimator assumptions and available domain bounds. - Refuters that run repeated simulations accept
num_simulations; several also acceptn_jobsandverbosethroughmodel.refute_estimate.
Minimal smoke checks
python scripts/smoke_causal_model.py --samples 1000 --seed 7 --tolerance 0.35
python scripts/parallel_refutation_template.py --num-simulations 3 --n-jobs 1
Both scripts are self-contained and perform no downloads. Use them to confirm a current Python environment can import DoWhy and run the classic workflow before adapting code to user data.
Response style
When answering, state the chosen identification strategy, estimator method name,
required columns, important method_params, one validation check, and one
refuter or sensitivity check. If routing away, name the sibling skill and the
reason. Do not point future agents to external notebooks, tests, or a source
checkout; distill the needed recipe here.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).