get_x1_main_effect: Extract Main Effect Contribution of the First Predictor Using Elastic Net
Description
This function fits a multivariate elastic net regression model (using glmnet)
to estimate the main effect contribution of the first predictor variable (x1)
in the provided data frame X for each response variable in V.
The main effect is forced into the model by setting its penalty factor to zero.
A numeric matrix of the same dimensions as V, where each column contains the estimated main effect contribution of x1 for the corresponding response variable.
Arguments
V
A numeric matrix of response variables (dimensions: observations x responses).
X
A data frame containing all predictor variables. The first column is treated as the target predictor (x1).
alpha
Elastic net mixing parameter (0 = ridge, 1 = lasso). Default is 1.
lambda
The value of the regularization parameter to use. Can be "lambda.min", "lambda.1se", or a specific numeric value. Default is "lambda.min".
Details
The function constructs a model matrix including all main effects and two-way interactions.
It then fits a multivariate elastic net model using cv.glmnet, forcing the inclusion of the main effect of x1 by setting its penalty factor to zero.
The resulting coefficients for x1 are used to compute its contribution to the fitted values for each response variable.