cv.glmreg_fit {mpath} | R Documentation |
Internal function of cross-validation for glmreg
Description
Internal function to conduct k-fold cross-validation for glmreg, produces a plot,
and returns cross-validated log-likelihood values for lambda
Usage
cv.glmreg_fit(x, y, weights, offset, lambda=NULL, balance=TRUE,
family=c("gaussian", "binomial", "poisson", "negbin"),
type=c("loss", "error"), nfolds=10, foldid, plot.it=TRUE,
se=TRUE, n.cores=2, trace=FALSE, parallel=FALSE, ...)
Arguments
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. |
lambda |
Optional user-supplied lambda sequence; default is
|
balance |
for |
family |
response variable distribution |
type |
cross-validation criteria. For |
nfolds |
number of folds >=3, default is 10 |
foldid |
an optional vector of values between 1 and |
plot.it |
a logical value, to plot the estimated log-likelihood values if |
se |
a logical value, to plot with standard errors. |
parallel , n.cores |
a logical value, parallel computing or not with the number of CPU cores to use. The cross-validation loop will attempt to send different CV folds off to different cores. |
trace |
a logical value, print progress of cross validation or not |
... |
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 |
cv |
The mean cross-validated log-likelihood values - a vector of
|
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.