Kappa Utilities¶
Functions for computing and exploring the kappa diagnostic, which measures theoretical imputation bias in the conditional independence test.
compute_kappa(r2_x_z, beta_yx, gamma_x)
¶
Theoretical imputation bias for CI testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r2_x_z
|
float
|
R-squared of X on observed covariates Z (i.e. 1 - Var(V)/Var(X)). In the single-proxy case this equals rho^2. |
required |
beta_yx
|
float
|
Coefficient of X in the Y equation. |
required |
gamma_x
|
float
|
Loading of X in the missingness equation. |
required |
Returns:
| Type | Description |
|---|---|
float
|
kappa = gamma_x * beta_yx * (1 - R2) / (1 + beta_yx^2 * (1 - R2)) |
kappa_calibration_table(r2_grid=None, beta_grid=None, gamma_grid=None)
¶
Produce a calibration table of kappa over realistic parameter ranges.
Default grids span typical survey / administrative data settings: R2 from poor to strong imputation, and partial effects in the 0.1-0.5 standardised range.
Returns:
| Type | Description |
|---|---|
pd.DataFrame with columns r2_x_z, beta_yx, gamma_x, kappa, abs_kappa.
|
|
print_calibration_pivot(df=None, beta_yx=0.3)
¶
Return a readable pivot: rows = R2, cols = gamma_x, for fixed beta_yx.
Useful for the appendix table. Call once per beta_yx value you want to display.