Introducing the b-value: combining unbiased and biased estimators from a sensitivity analysis perspective
Code accompanying the paper “Introducing the b-value: combining unbiased and biased estimators from a sensitivity analysis perspective” (Lin, Bickel, Ding; 2026). This repo implements three combined estimators, confidence intervals, and b-values.
You can use it to:
- compute combined point estimates (
PW,PT,ST) - compute CI under a bias bound
$b$ - compute the b-value: the smallest bias bound at which the CI first includes 0
-
estimators.py: combined point estimators from two inputs$(\hat\tau_0$ ,$\hat\tau_1)$ with variances$(\sigma_0^2, \sigma_1^2)$ .-
tau_pw: precision-weighted estimator. -
tau_pt: pretest estimator (uses a thresholding test at levelalpha). -
tau_st: soft-thresholding estimator (continuous shrinkage with thresholdalpha).
-
-
confidence_intervals.py: confidence interval functions under a bias bound$b$ .-
compute_L_PW,compute_L_PT,compute_L_ST: return the half-length.
-
-
compute_b_value.py: compute the b-value$b^*$ for each estimator (numerical root-finding on coverage/half-length conditions).-
compute_b_value_PW,compute_b_value_PT,compute_b_value_ST.
-
-
compute_b_values_demo.ipynb: end-to-end demo that computes estimators, CIs, and b-values for a simple parameter setup. -
plot_CI.ipynb: plots CIs as a function of the bias bound$b$ .
This is a lightweight, script-first repo (no package install required).
Create an environment and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install numpy scipy matplotlibCompute combined estimates, CI half-lengths, and b-values.
import numpy as np
from estimators import tau_pw, tau_pt, tau_st
from confidence_intervals import compute_L_PW, compute_L_PT, compute_L_ST
from compute_b_value import compute_b_value_PW, compute_b_value_PT, compute_b_value_ST
# Two estimates and their variances
tau0_hat = 1.0
tau1_hat = 2.0
sigma0_sq = 1.0
sigma1_sq = 0.1
# Convenience parameter
gamma = sigma0_sq / sigma1_sq
# Inference/decision levels
zeta = 0.05 # CI miscoverage level (95% CI)
alpha = 0.05 # PT/ST decision threshold
# Point estimates
pw = tau_pw(tau0_hat, tau1_hat, sigma0_sq, sigma1_sq)
pt = tau_pt(tau0_hat, tau1_hat, sigma0_sq, sigma1_sq, alpha=alpha)
st = tau_st(tau0_hat, tau1_hat, sigma0_sq, sigma1_sq, alpha=alpha)
# Robust CI half-lengths at a chosen bias bound b (where b = Δ/σ0)
b = 1.0
half_pw = compute_L_PW(b=b, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma)
half_pt = compute_L_PT(b=b, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma, alpha=alpha)
half_st = compute_L_ST(b=b, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma, alpha=alpha)
# b-values for each estimator (smallest b where robust CI includes 0)
bv_pw = compute_b_value_PW(tau_hat=pw, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma)
bv_pt = compute_b_value_PT(tau_hat=pt, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma, alpha=alpha)
bv_st = compute_b_value_ST(tau_hat=st, zeta=zeta, sigma0_sq=sigma0_sq, gamma=gamma, alpha=alpha)
print("point estimates:", pw, pt, st)
print("half-lengths @ b=1:", half_pw, half_pt, half_st)
print("b-values:", bv_pw, bv_pt, bv_st)- Run the b-value demo:
jupyter notebook compute_b_values_demo.ipynb- Plot CI half-lengths vs (b):
jupyter notebook plot_CI.ipynb- Link:
- Title: Introducing the b-value: combining unbiased and biased estimators from a sensitivity analysis perspective
- Authors: Zhexiao Lin, Peter J. Bickel, Peng Ding (2026)