functions used to calculate cross validation error and used by
the cv.sail
function
cv.lspath(outlist, lambda, x, y, e, weights, foldid, type.measure, grouped,
keep = FALSE)cvcompute(mat, weights, foldid, nlams)
getmin(lambda, cvm, cvsd)
lambda.interp(lambda, s)
list of cross validated fitted models. List is of length equal
to nfolds
argument in cv.sail
function
a user supplied lambda sequence. Typically, by leaving this
option unspecified users can have the program compute its own lambda
sequence based on nlambda
and lambda.factor
. Supplying a
value of lambda overrides this. It is better to supply a decreasing
sequence of lambda values than a single (small) value, if not, the program
will sort user-defined lambda sequence in decreasing order automatically.
Default: NULL
.
input matrix of dimension n x p
, where n
is the number
of subjects and p is number of X variables. Each row is an observation
vector. Can be a high-dimensional (n < p) matrix. Can be a user defined
design matrix of main effects only (without intercept) if
expand=FALSE
response variable. For family="gaussian"
should be a 1 column
matrix or numeric vector. For family="binomial"
, should be a 1
column matrix or numeric vector with -1 for failure and 1 for success.
exposure or environment vector. Must be a numeric vector. Factors must be converted to numeric.
observation weights. Default is 1 for each observation. Currently NOT IMPLEMENTED.
numeric vector indicating which fold each observation belongs to
loss to use for cross-validation. Currently only 3
options are implemented. The default is type.measure="deviance"
,
which uses squared-error for gaussian models (and is equivalent to
type.measure="mse"
) there). type.measure="mae"
(mean absolute
error) can also be used which measures the absolute deviation from the
fitted mean to the response (\(|y-\hat{y}|\)).
This is an experimental argument, with default TRUE
,
and can be ignored by most users. This refers to computing nfolds
separate statistics, and then using their mean and estimated standard error
to describe the CV curve. If grouped=FALSE
, an error matrix is built
up at the observation level from the predictions from the nfold
fits, and then summarized (does not apply to type.measure="auc"
).
Default: TRUE.
If keep=TRUE
, a prevalidated array is returned
containing fitted values for each observation and each value of
lambda
. This means these fits are computed with this observation and
the rest of its fold omitted. The folid
vector is also returned.
Default: FALSE
matrix of predictions
number of lambdas fit
mean cv error
sd of cv error
numeric value of lambda
cvcompute
: Computations for crossvalidation error
getmin
: get lambda.min and lambda.1se
lambda.interp
: Interpolation function.
The output of the cv.lspath
function only returns values for
those tuning parameters that converged. cvcompute, getmin,
lambda.interp
are taken verbatim from the glmnet
package
Jerome Friedman, Trevor Hastie, Robert Tibshirani (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. http://www.jstatsoft.org/v33/i01/.