cv.gamMRSea | R Documentation |
This function calculates the estimated K-fold cross-validation prediction error for gamMRSea models. It has been adapted from the cv.glm function from the boot
library
cv.gamMRSea(
data,
modelobject,
cost = function(y, yhat) mean((y - yhat)^2),
K = n,
replicate = FALSE,
s.eed = NULL
)
data |
A matrix or data frame containing the data. The rows should be cases and the columns correspond to variables, one of which is the response. |
modelobject |
An object of class "gamMRSea" containing the results of a gamMRSea model fitted to data. |
cost |
A function of two vector arguments specifying the cost function for the cross-validation. The first argument to cost should correspond to the observed responses and the second argument should correspond to the predicted or fitted responses from the generalized linear model. cost must return a non-negative scalar value. The default is the average squared error function. |
K |
The number of groups into which the data should be split to estimate the cross-validation prediction error. The value of K must be such that all groups are of approximately equal size. If the supplied value of K does not satisfy this criterion then it will be set to the closest integer which does and a warning is generated specifying the value of K used. The default is to set K equal to the number of observations in data which gives the usual leave-one-out cross-validation. |
replicate |
( |
s.eed |
( |
For more information please see the cv.glm function in the boot library
# load data
data(ns.data.re)
ns.data.re$foldid<-getCVids(ns.data.re, folds=5)
model<-gamMRSea(birds ~ observationhour + as.factor(floodebb) + as.factor(impact),
family='poisson', data=ns.data.re)
cv.gamMRSea(data=ns.data.re, modelobject = model, K=5)$delta
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.