The single interface to glmnet::cv.glmnet, which every glmnet fit in
the package goes through. It returns the fit, not weights:
glmnetWeights extracts the lambda.min coefficient
vector from it, while the mr.mash initialisation paths need the
coefficient matrix, the intercept row, the lambda sequence and
predict() on held-out rows — the same fit-versus-extract split as
fitMvsusie and mvsusieWeights.
Usage
fitGlmnetCv(
x,
y,
alpha,
family = NULL,
standardize = NULL,
intercept = NULL,
nfolds = NULL,
methodArgs = GlmnetOptions()
)Arguments
- x
Numeric design matrix (samples x features).
- y
Response: a vector, or a matrix for
family = "mgaussian".- alpha
Elastic-net mixing parameter in
[0, 1]:1= lasso,0= ridge,0.5= elastic net. The penalty family is the calling wrapper's to choose, which is whyGlmnetOptions()refuses it.- family
glmnet's response family, e.g.
"gaussian"or"mgaussian"for a matrix response.NULLleaves glmnet's own default.- standardize
Logical; standardize the columns of
xbefore fitting.NULLleaves glmnet's own default (TRUE).- intercept
Logical; fit an intercept.
NULLleaves glmnet's own default (TRUE).- nfolds
Number of cross-validation folds.
NULLleavescv.glmnet's own default (10).- methodArgs
Further arguments forwarded to
glmnet::cv.glmnet, built withGlmnetOptions. A bare list is refused, since it cannot be checked against the engine.
Value
The fit object returned by glmnet::cv.glmnet.
Details
The four knobs below are formals rather than GlmnetOptions
entries because they are what the package's glmnet call sites genuinely
differ on, and leaving them implicit is how three different conventions
came to coexist. Each defaults to NULL, meaning the argument is not
passed at all and cv.glmnet's own default stands; a value supplied
through methodArgs still wins over the caller's, so none of them is
refused by the constructor.