moderndid.compute_cck_ucb#
- moderndid.compute_cck_ucb(y, x, w, x_eval=None, alpha=0.05, boot_num=99, basis='tensor', j_x_degree=3, k_w_degree=4, knots='uniform', ucb_h=True, ucb_deriv=True, deriv_index=1, deriv_order=1, w_min=None, w_max=None, x_min=None, x_max=None, seed=None, selection_result=None)[source]#
Compute honest and adaptive UCBs.
Implements the data-driven uniform confidence band (UCB) construction from [1]. These UCBs are honest, guaranteeing uniform coverage over a class of data-generating processes, and adaptive, contracting at or near the minimax optimal rate.
The UCB for \(h_0\) is constructed as
\[C_n(x) = \left[\hat{h}_{\tilde{J}}(x) \pm \text{cv}^*(x) \hat{\sigma}_{\tilde{J}}(x)\right],\]where \(\tilde{J}\) is the data-driven dimension choice. The critical value \(\text{cv}^*(x)\) is a combination of a bootstrap quantile \(z_{1-\alpha}^*\) and a penalty term involving the critical value from the dimension selection step, \(\theta_{1-\hat{\alpha}}^*\).
For models in the “mildly ill-posed” regime (including nonparametric regression), the critical value is
\[\text{cv}^*(x) = z_{1-\alpha}^* + (\log\log\tilde{J}) \theta_{1-\hat{\alpha}}^*.\]The quantile \(z_{1-\alpha}^*\) is the \((1-\alpha)\) quantile of
\[\sup_{(x,J) \in \mathcal{X} \times \hat{\mathcal{J}}_-} |D_J^*(x) / \hat{\sigma}_J(x)|\]ensuring robustness to the choice of \(J\). A similar construction applies to the derivatives of \(h_0\). This method provides efficiency improvements over traditional undersmoothing by adapting to the data.
- Parameters:
- y
numpy.ndarray Dependent variable vector.
- x
numpy.ndarray Endogenous regressor matrix.
- w
numpy.ndarray Instrument matrix.
- x_eval
numpy.ndarray, optional Evaluation points for X. If None, uses x.
- alpha
float, default=0.05 Significance level (1-alpha confidence level).
- boot_num
int, default=99 Number of bootstrap replications.
- basis{“tensor”, “additive”, “glp”}, default=”tensor”
Type of basis for multivariate X.
- j_x_degree
int, default=3 Degree of B-spline basis for X.
- k_w_degree
int, default=4 Degree of B-spline basis for W.
- knots{“uniform”, “quantiles”}, default=”uniform”
Knot placement method.
- ucb_hbool, default=True
Whether to compute confidence bands for function estimates.
- ucb_derivbool, default=True
Whether to compute confidence bands for derivative estimates.
- deriv_index
int, default=1 Index (1-based) of X variable for derivative computation.
- deriv_order
int, default=1 Order of derivative to compute.
- w_min
float, optional Minimum value for W range.
- w_max
float, optional Maximum value for W range.
- x_min
float, optional Minimum value for X range.
- x_max
float, optional Maximum value for X range.
- seed
int, optional Random seed for reproducibility.
- selection_result
dict, optional Result from data-driven selection.
- y
- Returns:
NPIVResultNPIV results with CCK uniform confidence bands.
See also
compute_ucbCompute UCBs using under-smoothing
References
[1]Chen, X., Christensen, T. M., & Kankanala, S. (2024). Adaptive Estimation and Uniform Confidence Bands for Nonparametric Structural Functions and Elasticities. https://arxiv.org/abs/2107.11869.