Bootstrap Functions
These standalone functions are the lower-level interface; in most cases
using SW2023Model.bootstrap() is more convenient.
- sw2023.bootstrap_sw(X, Y, B=200, alpha=0.05, direction='mean', method='HMS', log_transform=True, standardize=True, bandwidth_method='silverman', seed=None, verbose=True)[source]
Pairs bootstrap confidence intervals for SW2023Model.
- To correctly compute individual observation CIs:
Fix the original direction vector d
Evaluate moment functions of resampled data at original Z points.
- Parameters:
X (Original data)
Y (Original data)
B (Number of bootstrap iterations)
alpha (Significance level (1-alpha confidence interval))
direction (Direction vector specification ('mean' | 'median' | array))
method ('HMS' | 'SVKZ')
log_transform (bool)
standardize (bool)
bandwidth_method ('silverman' | 'loocv' ('silverman' recommended for bootstrap))
seed (Random seed)
verbose (Print progress)
- Returns:
phi_hat_point : (n,) original frontier estimates phi_hat_ci : (n, 2) frontier confidence intervals eff_mean_point : float mean efficiency estimate eff_mean_ci : (2,) mean efficiency confidence interval eff_individual_point: (n,) individual efficiency estimates eff_individual_ci : (n, 2) individual efficiency confidence intervals sigma_eta_ci : (n, 2) sigma_eta confidence intervals B, alpha : parameters used
- Return type:
- sw2023.bootstrap_panel(X, Y, firm_id, time_id, B=200, alpha=0.05, direction='mean', method='HMS', log_transform=True, standardize=True, bandwidth_method='silverman', seed=None, verbose=True)[source]
Cluster bootstrap confidence intervals for PanelSW2023.
Resample by firm unit to preserve within-panel time-series dependence. Individual observation CIs are corrected in the same way as
bootstrap_sw: resample, transform with same d, then evaluate at original Z points.- Parameters:
X (Original data (n_total × ...))
Y (Original data (n_total × ...))
firm_id (Firm and time period identifiers (n_total,))
time_id (Firm and time period identifiers (n_total,))
(rest (same as bootstrap_sw))
- Returns:
Cluster bootstrap confidence intervals evaluated at the original observation points.
- Return type:
- sw2023.test_r3_significance(X, Y, direction='mean', method='HMS', log_transform=True, standardize=True, bandwidth_method='silverman', B=999, seed=None, verbose=True)[source]
Test whether inefficiency (eta) genuinely depends on observable covariates Z.
Null hypothesis H0: E(epsilon^3|Z) = const (spatially uniform inefficiency). Alternative H1: E(epsilon^3|Z) differs across Z (heterogeneous inefficiency).
PSVKZ(2024) Section 3.1 wild bootstrap (Rademacher perturbation):
Estimate r_hat_3(Z_i); compute residuals eta_i = eps_hat^3_i - r_hat_3(Z_i).
Center: eta^c_i = eta_i - mean(eta).
Wild perturbation: eta*_i = eta^c_i x V_i, V_i ~ Rademacher(+-1, 50% each).
Bootstrap response: eps_hat^3*_i = r_hat_3(Z_i) + eta*_i.
Re-estimate r_hat*_3(Z) and compute T*_b.
p-value = #{T*_b >= T_obs} / B.
Test statistic (variance-weighted average heterogeneity): T = Var(r_hat_3) / Var(eps_hat^3).
- Parameters:
X (Original data)
Y (Original data)
direction (Direction vector)
method ('HMS' | 'SVKZ')
bandwidth_method (Bandwidth method)
B (Number of bootstrap iterations (default 999))
seed (Random seed)
verbose (Print output)
- Returns:
statistic : float observed test statistic T p_value : float bootstrap p-value r3_hat : (n,) estimated r_hat_3(Z) T_boot : (B,) bootstrap distribution of T B : int
- Return type: