multinomreg.cv: Cross-validation for the multinomial regression

View source: R/multinomreg.cv.R

Cross-validation for the multinomial regressionR Documentation

Cross-validation for the multinomial regression

Description

Cross-validation for the multinomial regression.

Usage

multinomreg.cv(y, x, folds = NULL, nfolds = 10, stratified = TRUE, 
               seed = FALSE, pred.ret = FALSE)

Arguments

y

The response variable. A numerical or a factor type vector.

x

A matrix or a data.frame with the predictor variables.

folds

A list with the indices of the folds.

nfolds

The number of folds to be used. This is taken into consideration only if "folds" is NULL.

stratified

Do you want the folds to be selected using stratified random sampling? This preserves the analogy of the samples of each group. Make this TRUE if you wish, but only for the classification. If you have regression (type = "R"), do not put this to TRUE as it will cause problems or return wrong results.

seed

If you set this to TRUE, the same folds will be created every time.

pred.ret

If you want the predicted values returned set this to TRUE.

Value

A list including:

preds

If pred.ret is TRUE the predicted values for each fold are returned as elements in a list.

crit

A vector whose length is equal to the number of k and is the accuracy metric for each k. For the classification case it is the percentage of correct classification.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

References

Friedman J., Hastie T. and Tibshirani R. (2017). The elements of statistical learning. New York: Springer.

Bohning, D. (1992). Multinomial logistic regression algorithm. Annals of the Institute of Statistical Mathematics, 44(1): 197-200.

See Also

bigknn.cv, mle.lda, reg.mle.lda

Examples

x <- as.matrix(iris[, 1:2])
mod <- multinomreg.cv(iris[, 5], x)

Rfast2 documentation built on Aug. 8, 2023, 1:11 a.m.