cv.lspath: Compute cross validation error

Description Usage Arguments Details Functions References See Also

View source: R/cv.sail.R

Description

functions used to calculate cross validation error and used by the cv.sail function

Usage

1
2
3
4
5
6
7
8
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)

Arguments

outlist

list of cross validated fitted models. List is of length equal to nfolds argument in cv.sail function

lambda

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.

x

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

y

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.

e

exposure or environment vector. Must be a numeric vector. Factors must be converted to numeric.

weights

observation weights. Default is 1 for each observation. Currently NOT IMPLEMENTED.

foldid

numeric vector indicating which fold each observation belongs to

type.measure

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}|).

grouped

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.

keep

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

mat

matrix of predictions

nlams

number of lambdas fit

cvm

mean cv error

cvsd

sd of cv error

s

numeric value of lambda

Details

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

Functions

References

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/.

See Also

cv.sail


sahirbhatnagar/sail documentation built on July 17, 2021, 5:10 a.m.