cv.nclreg_fit function

Internal function of cross-validation for nclreg

Internal function of cross-validation for nclreg

Internal function to conduct k-fold cross-validation for nclreg, produces a plot, and returns cross-validated loss values for lambda

cv.nclreg_fit(x, y, weights, offset, lambda=NULL, balance=TRUE, rfamily=c("clossR", "closs", "gloss", "qloss"), s=1.5, nfolds=10, foldid, type = c("loss", "error"), plot.it=TRUE, se=TRUE, n.cores=2, trace=FALSE, parallel=FALSE, ...)

Arguments

  • x: x matrix as in nclreg.

  • y: response y as in nclreg.

  • weights: Observation weights; defaults to 1 per observation

  • offset: this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. Currently only one offset term can be included in the formula.

  • lambda: Optional user-supplied lambda sequence; default is NULL, and nclreg chooses its own sequence

  • balance: for rfamily="closs", "gloss", "qloss" only

  • rfamily: response variable distribution and nonconvex loss function

  • s: nonconvex loss tuning parameter for robust regression and classification.

  • nfolds: number of folds >=3, default is 10

  • foldid: an optional vector of values between 1 and nfold

    identifying what fold each observation is in. If supplied, nfold can be missing and will be ignored.

  • type: cross-validation criteria. For type="loss", loss function values and type="error" is misclassification error.

  • plot.it: a logical value, to plot the estimated loss values if TRUE.

  • se: a logical value, to plot with standard errors.

  • n.cores: The number of CPU cores to use. The cross-validation loop will attempt to send different CV folds off to different cores.

  • trace: a logical value, print progress of cross validation or not

  • parallel: a logical value, parallel computing or not

  • ...: Other arguments that can be passed to nclreg.

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.

Returns

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 or errors with row values for lambda and column values for kth cross-validation

  • cv: The mean cross-validated loss values or errors - 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.

References

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

Author(s)

Zhu Wang zwang145@uthsc.edu

See Also

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

  • Maintainer: Zhu Wang
  • License: GPL-2
  • Last published: 2024-06-27