compute_bias
Demonstrate the bias of a proposed adjustment set by simulating data from a linear SEM, comparing crude and adjusted regression estimates against the true causal effect, and reporting the bias reduction.
Instructions
Numerically demonstrate the bias of a proposed adjustment set. Computes the true total effect analytically from the SEM edge coefficients (sum of products along all directed X→Y paths), then fits two OLS regressions on simulated data: crude (Y ~ X) and adjusted (Y ~ X + Z). Reports each estimate, each bias against the true effect, and the bias reduction |crude_bias| − |adjusted_bias|.
Translates a structural claim ("adjust for {age, smoking}") into a numerical demonstration. Composes check_overadjustment internally — any overadjustment flags emitted there are surfaced in this tool's diagnostics as well, so a single call captures both the numerical bias and the structural reason for it.
Outputs are conditional on the linear Gaussian SEM (see simulate_data for assumptions).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Sample size. Default 1000, maximum 10000. | |
| dag | Yes | ||
| seed | No | Deterministic seed. Default 42. | |
| coefficients | No | Optional edge-keyed coefficient overrides, e.g. {'X->Y': 0.8}. Edges not listed use the default 0.5. | |
| adjustment_set | Yes |