---
title: "Debiased inference, wild bootstrap, and Efron's bootstrap"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Debiased inference, wild bootstrap, and Efron's bootstrap}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```
```{r smoke-data, include=FALSE}
set.seed(2026)
n_smoke <- 140
p_smoke <- 6
X_smoke <- matrix(rnorm(n_smoke * p_smoke), n_smoke, p_smoke)
colnames(X_smoke) <- paste0("x", seq_len(p_smoke))
beta_smoke <- c(1.0, -0.8, 0.6, 0, 0, 0)
T_smoke <- rexp(n_smoke, rate = 0.05 * exp(drop(X_smoke %*% beta_smoke)))
C_smoke <- rexp(n_smoke, rate = 0.025)
time_smoke <- pmin(T_smoke, C_smoke)
status_smoke <- as.integer(T_smoke <= C_smoke)
library(selSurv)
fit_smoke <- coxlasso_fit(X_smoke, time_smoke, status_smoke, lambda_choice = "1se")
```


This vignette covers inference for the debiased Cox-Lasso estimator. The debiased estimator targets full-model coefficients; it is conceptually distinct from inference for an unpenalized refit on a selected support.

## Debiased estimator

Let `fit` be the result of `coxlasso_fit()`. The package applies the score-based correction and estimates the inverse-information directions by nodewise regression.

```{r debias, eval=FALSE}
db <- coxlasso_debias(fit)
summary(db)
```

The implementation keeps the original Cox-Lasso pilot and the estimated nodewise correction available for subsequent bootstrap inference.

## Wild bootstrap and Efron's bootstrap

Both bootstrap constructions operate on the debiased representation rather than repeating Cox-Lasso fitting and nodewise estimation in every bootstrap sample.

```{r bootstrap, eval=FALSE}
db_boot <- coxlasso_boot(
  fit,
  inference = "debiased",
  type = c("wild", "efron"),
  B = 500,
  conf_level = 0.95,
  seed = 2026
)
summary(db_boot)
```

The string `"efron"` is the software argument naming Efron's bootstrap. In prose, the method is referred to as **Efron's bootstrap**.


```{r debias-smoke, include=FALSE}
db_smoke <- coxlasso_debias(fit_smoke)
summary(db_smoke)

db_boot_smoke <- coxlasso_boot(
  fit_smoke,
  inference = "debiased",
  type = c("wild", "efron"),
  B = 3L,
  conf_level = 0.95,
  seed = 2026
)
summary(db_boot_smoke)
```

## Interpretation

The wild bootstrap and Efron's bootstrap approximate uncertainty for the debiased full-model coefficient target. They should not be interpreted as fixed-support or selection-conditional inference. The methodological details and theoretical justification are developed in *Wild Bootstrap and Efron's Bootstrap for Debiased Cox Regression*.
