learn_omitted_variable_bias

source

learn_omitted_variable_bias(n=2000, beta_x=1.0, beta_z=1.0, corr_xz=0.6, seed=0)

Show how omitting a correlated confounder biases a regression coefficient.

Simulates y = beta_x * x + beta_z * z + noise where x and the confounder z are correlated (corr_xz), then compares the short regression (omitting z) with the long regression (controlling for z).

Parameters

Name Type Description Default
n int Sample size. 2000
beta_x float True effect of the focal regressor x. 1.0
beta_z float True effect of the omitted confounder z. 1.0
corr_xz float Correlation between x and z (drives the bias). 0.6
seed int Random seed. 0

Returns

Name Type Description
SandboxResult df (short vs long vs true coefficient), fig, summary and topic.

Examples

These sandboxes generate their own data, so a call needs no DataFrame — turn the knobs via the keyword parameters:

import expdpy as ex

res = ex.learn_omitted_variable_bias()
res.fig