import expdpy as ex
res = ex.learn_measurement_error()
res.figlearn_measurement_error
learn_measurement_error(n=4000, beta=1.0, noise_x=1.0, seed=0)Show classical measurement-error attenuation: noise in the regressor biases OLS to zero.
Simulates y = beta*x_true + e but regresses on a noisy observation x_obs = x_true + u. The OLS slope is attenuated toward zero by the reliability ratio var(x_true) / (var(x_true) + var(u)).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| n | int | Sample size. | 4000 |
| beta | float | True slope on the (unobserved) x_true. |
1.0 |
| noise_x | float | Standard deviation of the measurement noise added to x_true (drives the attenuation). |
1.0 |
| seed | int | Random seed. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| SandboxResult | df (naive vs true slope), fig, summary and topic. |
Examples
This sandbox simulates its own data, so the call needs no DataFrame: