Plot a cv.vda.r object

Share:

Description

Plot a the cross validation error across lambda values

Usage

1
2
## S3 method for class 'cv.vda.r'
plot(x, ...)

Arguments

x

Object of class 'cv.vda.r', the result of a call to cv.vda.r.

...

Not used.

Details

Plots the k-fold cross validation testing error for values across a different lambda values. Use cv.vda.r to produce the object of class "cv.vda.r."

Author(s)

Edward Grant, Xia Li, Kenneth Lange, Tong Tong Wu

Maintainer: Edward Grant edward.m.grant@gmail.com

References

Lange, K. and Wu, T.T. (2008) An MM Algorithm for Multicategory Vertex Discriminant Analysis. Journal of Computational and Graphical Statistics, Volume 17, No 3, 527-544.

See Also

vda.r, cv.vda.r

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# load data
data(zoo)

# feature matrix without intercept
x <- zoo[,2:17]

# class vector
y <- zoo[,18]

# lambda vector
lam.vec <- (1:10)/10

# run 10 fold cross validation across lambdas
cv <- cv.vda.r(x, y, 10, lam.vec)

# plot CV results
plot(cv)

# Perform VDA with CV-selected optimal lambda
out <- vda.r(x,y,cv$lam.opt)

# Predict five cases based on VDA
fivecases <- matrix(0,5,16)
fivecases[1,] <- c(1,0,0,1,0,0,0,1,1,1,0,0,4,0,1,0)
fivecases[2,] <- c(1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1)
fivecases[3,] <- c(0,1,1,0,1,0,0,0,1,1,0,0,2,1,1,0)
fivecases[4,] <- c(0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0)
fivecases[5,] <- c(0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0)
predict(out, fivecases)