Learn R Programming

mpath (version 0.4-2.26)

cv.nclreg: Cross-validation for nclreg

Description

Does k-fold cross-validation for nclreg, produces a plot, and returns cross-validated loss values for lambda

Usage

# S3 method for formula
cv.nclreg(formula, data, weights, offset=NULL, ...)
# S3 method for matrix
cv.nclreg(x, y, weights, offset=NULL, ...)
# S3 method for default
cv.nclreg(x,  ...)
# S3 method for cv.nclreg
plot(x,se=TRUE,ylab=NULL, main=NULL, width=0.02, col="darkgrey", ...)
# S3 method for cv.nclreg
coef(object,which=object$lambda.which, ...)

Value

an object of class "cv.nclreg" is returned, which is a list with the ingredients of the cross-validation fit.

fit

a fitted nclreg object for the full data.

residmat

matrix of loss values with row values for lambda and column values for kth cross-validation

bic

matrix of BIC values with row values for lambda and column values for kth cross-validation

cv

The mean cross-validated loss values - a vector of length length(lambda).

cv.error

estimate of standard error of cv.

foldid

an optional vector of values between 1 and nfold identifying what fold each observation is in.

lambda

a vector of lambda values

lambda.which

index of lambda that gives minimum cv value.

lambda.optim

value of lambda that gives minimum cv value.

Arguments

formula

symbolic description of the model, see details.

data

argument controlling formula processing via model.frame.

x

x matrix as in nclreg. It could be object of cv.nclreg.

y

response y as in nclreg.

weights

Observation weights; defaults to 1 per observation

offset

Not implemented yet

object

object of cv.nclreg

which

Indices of the penalty parameter lambda at which estimates are extracted. By default, the one which generates the optimal cross-validation value.

se

logical value, if TRUE, standard error curve is also plotted

ylab

ylab on y-axis

main

title of plot

width

width of lines

col

color of standard error curve

...

Other arguments that can be passed to nclreg.

Author

Zhu Wang <zwang145@uthsc.edu>

Details

The function runs nclreg nfolds+1 times; the first to compute the lambda sequence, and then to compute the fit with each of the folds omitted. The error or the loss value is accumulated, and the average value and standard deviation over the folds is computed. Note that cv.nclreg can be used to search for values for alpha: it is required to call cv.nclreg with a fixed vector foldid for different values of alpha.

References

Zhu Wang (2021), MM for Penalized Estimation, TEST, tools:::Rd_expr_doi("10.1007/s11749-021-00770-2")

See Also

nclreg and plot, predict, and coef methods for "cv.nclreg" object.