Last chance! 50% off unlimited learning
Sale ends in
"plot"(x, log.l=TRUE, type=c("cve", "rsq", "scale",
"snr", "pred", "all"), selected=TRUE, vertical.line=TRUE, col="red",
...)
"cv.ncvreg"
object.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.TRUE
(the default), places an axis on top of
the plot denoting the number of variables in the model (i.e., that
have a nonzero regression coefficient) at that value of
lambda
.TRUE
(the default), draws a vertical
line at the value where cross-validaton error is minimized.plot
lambda
. For
rsq
and snr
, these confidence intervals are quite crude,
especially near zero, and will hopefully be improved upon in later
versions of ncvreg
.ncvreg
, cv.ncvreg
## Linear regression
data(prostate)
X <- as.matrix(prostate[,1:8])
y <- prostate$lpsa
cvfit <- cv.ncvreg(X, y)
plot(cvfit)
par(mfrow=c(2,2))
plot(cvfit, type="all")
## Logistic regression
data(heart)
X <- as.matrix(heart[,1:9])
y <- heart$chd
cvfit <- cv.ncvreg(X, y, family="binomial")
plot(cvfit)
par(mfrow=c(2,2))
plot(cvfit, type="all")
Run the code above in your browser using DataLab