DOC 03 / 06Artificial Example
Binary-response simulation with known support
A fixed-seed logit design in which the true support is known before the selection procedure is run.
Design
Known sparse support
The simulation contains 250 observations and 20 independent standard-normal candidate variables. The binary response is generated from a logit index containing only x1 and x3.
\[\Pr(y_i=1\mid X_i)=\Lambda\!\left(1.5x_{1i}-x_{3i}\right)\]
| Observations | 250 |
|---|---|
| Candidates | 20 |
| True support | x1, x3 |
| Link | Logit |
| Seed | 123 |
Reproduction
Selection code and result
R simulation
library(BoostingMultipleTesting)
set.seed(123)
n_obs <- 250
n_candidates <- 20
X <- matrix(
stats::rnorm(n_obs * n_candidates),
nrow = n_obs,
ncol = n_candidates
)
colnames(X) <- paste0("x", seq_len(n_candidates))
eta <- 1.5 * X[, "x1"] - X[, "x3"]
probability <- stats::plogis(eta)
y <- stats::rbinom(n_obs, size = 1, prob = probability)
selected <- boosting_glm(
y = y,
X = X,
link = "logit",
pval = 0.05,
delta1 = 1
)
colnames(X)[selected]
Output
[1] "x1" "x3"
The computed website result matches the data-generating support for this fixed seed: x1 and x3 are selected.
Post-selection model
Estimate on the selected columns
The selection vector can be used directly to subset the candidate matrix before estimating the final logit model.
R
simulation_data <- data.frame(
y = y,
X[, selected, drop = FALSE],
check.names = FALSE
)
final_model <- stats::glm(
y ~ .,
data = simulation_data,
family = stats::binomial("logit")
)
coef(summary(final_model))