fit_all_subset_linear_models {PoSIAdjRSquared} | R Documentation |
Fit all subset linear models
Description
This function fits all possible combinations of linear models and returns the selected model based on adjusted R^2.
Usage
fit_all_subset_linear_models(y, X, intercept)
Arguments
y |
Response vector of type "matrix" and dimension nx1 |
X |
Design matrix of type "matrix" and dimension nxp |
intercept |
Logical value: TRUE if fitted models should contain intercept, FALSE if not |
Value
k |
Index set included in model k |
best_model |
The selected model fit (lm object) |
phat |
Index set included in the selected model |
X_M_phat |
The design matrix in the selected model |
best_adj_r_squared |
The adjusted R^2 value of the selected model |
R_M_phat |
The orthogonal projection matrix of the selected model |
kappa_M_phat |
Adjustment factor for model complexity kappa of the selected model |
R_M_k |
The orthogonal projection matrix of model k |
kappa_M_k |
Adjustment factor for model complexity kappa of model k |
References
Pirenne, S. and Claeskens, G. (2024). Exact Post-Selection Inference for Adjusted R Squared.
Examples
# 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)