CVcluster: Cross-validation estimate of predictive accuracy for...

Description Usage Arguments Value Author(s) References Examples

Description

This function adapts cross-validation to work with clustered categorical outcome data. For example, there may be multiple observations on individuals (clusters). It requires a fitting function that accepts a model formula.

Usage

1
2
3
CVcluster(formula, id, data, na.action=na.omit, nfold = 15, FUN = MASS::lda,
              predictFUN=function(x, newdata, ...)predict(x, newdata, ...)$class,
              printit = TRUE, cvparts = NULL, seed = 29)

Arguments

formula

Model formula

id

numeric, identifies clusters

data

data frame that supplies the data

na.action

na.fail (default) or na.omit

nfold

Number of cross-validation folds

FUN

function that fits the model

predictFUN

function that gives predicted values

printit

Should summary information be printed?

cvparts

Use, if required, to specify the precise folds used for the cross-validation. The comparison between different models will be more accurate if the same folds are used.

seed

Set seed, if required, so that results are exactly reproducible

Value

class

Predicted values from cross-validation

CVaccuracy

Cross-validation estimate of accuracy

confusion

Confusion matrix

Author(s)

John Maindonald

References

https://maths-people.anu.edu.au/~johnm/nzsr/taws.html

Examples

1
2
3
4
5
6
if(requireNamespace('mlbench')&requireNamespace('MASS')){
data('Vowel',package='mlbench')
acc <- CVcluster(formula=Class ~., id = V1, data = Vowel, nfold = 15, FUN = MASS::lda,
              predictFUN=function(x, newdata, ...)predict(x, newdata, ...)$class,
                     printit = TRUE, cvparts = NULL, seed = 29)
}

gamclass documentation built on Nov. 14, 2020, 1:07 a.m.