powered by
This function fits all possible combinations of linear models and returns the selected model based on adjusted R^2.
fit_all_subset_linear_models(y, X, intercept)
Index set included in model k
The selected model fit (lm object)
Index set included in the selected model
The design matrix in the selected model
The adjusted R^2 value of the selected model
The orthogonal projection matrix of the selected model
Adjustment factor for model complexity kappa of the selected model
The orthogonal projection matrix of model k
Adjustment factor for model complexity kappa of model k
Response vector of type "matrix" and dimension nx1
Design matrix of type "matrix" and dimension nxp
Logical value: TRUE if fitted models should contain intercept, FALSE if not
Pirenne, S. and Claeskens, G. (2024). Exact Post-Selection Inference for Adjusted R Squared.
# Generate data Data <- datagen.norm(seed = 7, n = 100, p = 3, rho = 0, beta_vec = c(1,0.5,0)) X <- Data$X y <- Data$y # Select model fit_all_subset_linear_models(y, X, intercept=FALSE)
Run the code above in your browser using DataLab