lambda
cv.glmregNB(formula, data, weights, lambda=NULL,
nfolds=10, foldid, plot.it=TRUE, se=TRUE, trace=FALSE,...)
model.frame
.NULL
, and glmregNB
chooses its own sequencenfolds
can be as large as the sample size (leave-one-out CV), it is not
recommended for large datasets. Smallest value allowable is nfolds=3
nfold
identifying what fold each observation is in. If supplied,
nfold
can be missing.TRUE
.TRUE
, shows cross-validation progressglmregNB
."cv.glmregNB"
is returned, which is a
list with the ingredients of the cross-validation fit.lambda
and column values for k
th cross-validationlength(lambda)
.length(lambda)
.lambda
values with length of lambda
lambda
that gives maximum cv
value.lambda
that gives maximum cv
value.glmregNB
nfolds
+1 times; the
first to get the lambda
sequence, and then the remainder to
compute the fit with each of the folds omitted. The error is
accumulated, and the average error and standard deviation over the
folds is computed.
Note that cv.glmregNB
does NOT search for
values for alpha
. A specific value should be supplied, else
alpha=1
is assumed by default. If users would like to
cross-validate alpha
as well, they should call cv.glmregNB
with a pre-computed vector foldid
, and then use this same fold vector
in separate calls to cv.glmregNB
with different values of
alpha
.glmregNB
and plot
, predict
, and coef
methods for "cv.glmregNB"
object.data("bioChemists", package = "pscl")
fm_nb <- cv.glmregNB(art ~ ., data = bioChemists)
plot(fm_nb)
Run the code above in your browser using DataLab