Selecting Variables in High Dimensional Data
Given a dataset with n samples and p features where p is large (possibly p >> n):
- Check the n/p ratio and correlation structure among covariates.
- Standardize features; center the response.
- Fit a penalized model as a baseline:
R
library(glmnet) cv_fit <- cv.glmnet(X, y, alpha = 1) # LASSO coef(cv_fit, s = "lambda.min") - If sparsity assumptions are weak or you need uncertainty quantification, fit a Bayesian shrinkage model (e.g., spike-and-slab or horseshoe) instead of/alongside LASSO.
- Validate selected variables via stability selection or cross-validated prediction error, not just in-sample fit.
Progress:
- Step 1: Characterize the problem (n vs p, signal sparsity, correlation among predictors, response type: continuous/binary/survival)
- Step 2: Choose a modeling framework (frequentist penalization vs Bayesian shrinkage) based on goals (point estimate vs full posterior/uncertainty)
- Step 3: Select and fit an appropriate method
- Step 4: Tune hyperparameters (penalty λ, prior scale) via cross-validation or empirical Bayes
- Step 5: Assess stability and control false discoveries
- Step 6: Validate on held-out data and interpret selected model
Step 1: Characterize the problem
- If p > n substantially: assume sparsity is necessary for identifiability.
- Check pairwise correlations: high collinearity favors elastic net or group-structured penalties over plain LASSO.
- Note response type to pick the right base model (linear, logistic, Cox).
Step 2: Choose a framework
Frequentist (penalization-based) — fast, scalable, good default for point estimates:
- LASSO (L1): sparse solutions, but biased estimates and unstable selection under correlation.
- Ridge (L2): no sparsity, use only for prediction with dense signals.
- Elastic Net: L1+L2, handles grouped/correlated predictors.
- SCAD / MCP: non-convex penalties reducing bias of LASSO, harder to optimize but better oracle properties.
- Group LASSO / Sparse Group LASSO: when predictors have natural grouping (e.g., dummy variables, pathways).
Bayesian (prior-based shrinkage) — better uncertainty quantification, natural handling of multiplicity:
- Spike-and-slab priors: explicit variable inclusion/exclusion, gives posterior inclusion probabilities.
- Continuous shrinkage priors (horseshoe, Bayesian LASSO, normal-gamma): easier computation (no combinatorial search), good adaptive shrinkage.
- Empirical Bayes: estimate prior hyperparameters (e.g., sparsity level) from data — preferred over fully subjective priors in high dimensions.
- Objective/reference priors: when no strong prior information exists.
Step 3: Fit the method
Use established software (glmnet, ncvreg for SCAD/MCP, BoomSpikeSlab/horseshoe packages) rather than custom optimization unless justified.
Step 4: Tune hyperparameters
- Frequentist: k-fold CV on prediction loss; consider CV on multiple λ's along the path, not just lambda.min (use lambda.1se for parsimony).
- Bayesian: empirical Bayes marginal likelihood maximization, or hierarchical priors with hyperpriors on sparsity/shrinkage parameters.
Step 5: Assess stability & control false discoveries
- Stability selection: resample/subsample and check selection frequency of each variable; keep variables selected above a threshold.
- Knockoffs: construct knockoff variables to control FDR rigorously in high dimensions.
- Posterior inclusion probability thresholds (Bayesian): e.g., select variables with PIP > 0.5 (median probability model).
Step 6: Validate
- Hold out a test set or use nested CV to get honest prediction error.
- Check selected model against domain knowledge (e.g., known relevant genes/pathways).
- Report uncertainty: confidence/credible intervals for selected effects using post-selection inference or Bayesian posteriors.
Example 1: Input: Gene expression dataset, n=150 samples, p=20,000 genes, binary disease outcome. Output: Use sparse logistic regression with LASSO or elastic net (correlated gene pathways favor elastic net); tune λ via 10-fold CV on deviance; validate selected genes via stability selection across 100 bootstrap resamples; report final model with genes selected in >80% of resamples, cross-validated AUC, and known pathway annotations for interpretation.
Example 2: Input: Genomic dataset with strong prior belief that only a small fraction of SNPs are causal, and researcher wants posterior probability of association for each SNP. Output: Fit a Bayesian spike-and-slab linear model with empirical-Bayes-estimated sparsity level; use MCMC or variational inference for posterior inclusion probabilities; report SNPs with PIP > 0.5 (median probability model) along with 95% credible intervals for effect sizes.
- Default to elastic net or SCAD over plain LASSO when predictors are correlated — reduces instability of selection.
- Prefer empirical Bayes over fully subjective priors in high-dimensional settings; there's rarely genuine prior knowledge on tens of thousands of parameters.
- Always separate variable selection from inference: don't report naive p-values/CIs on LASSO-selected coefficients — use post-selection inference (e.g., selective inference, debiased/desparsified LASSO) or Bayesian posteriors.
- Use stability selection or knockoffs when false discovery control matters (e.g., biomedical applications with downstream costly validation).
- Consider computational scalability explicitly: coordinate descent (glmnet) scales to huge p; full MCMC for spike-and-slab may not — use variational Bayes or EM-based approaches for very large p.
- Match penalty/prior structure to known data structure (grouping, hierarchy, temporal/spatial structure) rather than using an unstructured method by default.
- Reporting LASSO coefficient magnitudes/p-values as if from standard OLS — invalid due to selection bias.
- Using lambda.min blindly, leading to overfit/unstable variable sets; consider lambda.1se or stability-based selection.
- Ignoring correlation structure and using plain LASSO, which arbitrarily picks one variable from a correlated group.
- Treating Bayesian priors as fully subjective/hand-tuned in high dimensions — instead estimate hyperparameters from data (empirical Bayes) or use hierarchical priors.
- Skipping out-of-sample validation and judging model quality purely on in-sample fit or BIC/AIC computed without regard to high-dimensional corrections.
- Assuming sparsity always holds — check whether a dense-signal model (ridge-type) fits better before forcing a sparse solution.