cv.glmreg {mpath} | R Documentation |
Cross-validation for glmreg
Description
Does k-fold cross-validation for glmreg, produces a plot,
and returns cross-validated log-likelihood values for lambda
Usage
## S3 method for class 'formula'
cv.glmreg(formula, data, weights, offset=NULL, contrasts=NULL, ...)
## S3 method for class 'matrix'
cv.glmreg(x, y, weights, offset=NULL, ...)
## Default S3 method:
cv.glmreg(x, ...)
## S3 method for class 'cv.glmreg'
plot(x,se=TRUE,ylab=NULL, main=NULL, width=0.02, col="darkgrey", ...)
## S3 method for class 'cv.glmreg'
predict(object, newx, ...)
## S3 method for class 'cv.glmreg'
coef(object,which=object$lambda.which, ...)
Arguments
formula |
symbolic description of the model, see details. |
data |
argument controlling formula processing
via |
x |
|
y |
response |
weights |
Observation weights; defaults to 1 per observation |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. Currently only one offset term can be included in the formula. |
contrasts |
the contrasts corresponding to |
object |
object of |
newx |
Matrix of values at which predictions are to be made. Not
used for |
which |
Indices of the penalty parameter |
se |
logical value, if |
ylab |
ylab on y-axis |
main |
title of plot |
width |
width of lines |
col |
color of standard error curve |
... |
Other arguments that can be passed to |
Details
The function runs glmreg
nfolds
+1 times; the
first to compute the lambda
sequence, and then to
compute the fit with each of the folds omitted. The error or the log-likelihood value is
accumulated, and the average value and standard deviation over the
folds is computed. Note that cv.glmreg
can be used to search for
values for alpha
: it is required to call cv.glmreg
with a fixed vector foldid
for different values of alpha
.
Value
an object of class "cv.glmreg"
is returned, which is a
list with the ingredients of the cross-validation fit.
fit |
a fitted glmreg object for the full data. |
residmat |
matrix of log-likelihood values with row values for |
bic |
matrix of BIC values with row values for |
cv |
The mean cross-validated log-likelihood values - a vector of length
|
cv.error |
estimate of standard error of |
foldid |
an optional vector of values between 1 and |
lambda |
a vector of |
lambda.which |
index of |
lambda.optim |
value of |
Author(s)
Zhu Wang <zwang145@uthsc.edu>
References
Zhu Wang, Shuangge Ma, Michael Zappitelli, Chirag Parikh, Ching-Yun Wang and Prasad Devarajan (2014) Penalized Count Data Regression with Application to Hospital Stay after Pediatric Cardiac Surgery, Statistical Methods in Medical Research. 2014 Apr 17. [Epub ahead of print]
See Also
glmreg
and plot
, predict
, and coef
methods for "cv.glmreg"
object.
Examples
data("bioChemists", package = "pscl")
fm_pois <- cv.glmreg(art ~ ., data = bioChemists, family = "poisson")
title("Poisson Family",line=2.5)
predict(fm_pois, newx=bioChemists[,-1])[1:4]
coef(fm_pois)