plot-cv-grpreg: Plots the cross-validation curve from a 'cv.grpreg' object

Description Usage Arguments Details Author(s) See Also Examples

Description

Plots the cross-validation curve from a cv.grpreg object, along with standard error bars.

Usage

1
2
3
4
## S3 method for class 'cv.grpreg'
plot(x, log.l=TRUE, type=c("cve", "rsq", "scale",
"snr", "pred", "all"),  selected=TRUE, vertical.line=TRUE, col="red",
...)

Arguments

x

A cv.grpreg object.

log.l

Should horizontal axis be on the log scale? Default is TRUE.

type

What to plot on the vertical axis. cve plots the cross-validation error (deviance); rsq plots an estimate of the fraction of the deviance explained by the model (R-squared); snr plots an estimate of the signal-to-noise ratio; scale plots, for family="gaussian", an estimate of the scale parameter (standard deviation); pred plots, for family="binomial", the estimated prediction error; all produces all of the above.

selected

If TRUE (the default), places an axis on top of the plot denoting the number of groups in the model (i.e., that contain a nonzero regression coefficient) at that value of lambda.

vertical.line

If TRUE (the default), draws a vertical line at the value where cross-validaton error is minimized.

col

Controls the color of the dots (CV estimates).

...

Other graphical parameters to plot

Details

Error bars representing approximate +/- 1 SE (68% confidence intervals) are plotted along with the estimates at value of lambda. For rsq and snr, these confidence intervals are quite crude, especially near zero, and will hopefully be improved upon in later versions of grpreg.

Author(s)

Patrick Breheny

See Also

grpreg, cv.grpreg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Birthweight data
data(Birthwt)
X <- Birthwt$X
group <- Birthwt$group

# Linear regression
y <- Birthwt$bwt
cvfit <- cv.grpreg(X, y, group)
plot(cvfit)
par(mfrow=c(2,2))
plot(cvfit, type="all")

## Logistic regression
y <- Birthwt$low
cvfit <- cv.grpreg(X, y, group, family="binomial")
plot(cvfit)
par(mfrow=c(2,2))
plot(cvfit, type="all")

Example output

Loading required package: Matrix

grpreg documentation built on July 27, 2021, 1:08 a.m.