CVgam: Cross-validation estimate of accuracy from GAM model fit

Description Usage Arguments Value Author(s) References Examples

Description

The cross-validation estimate of accuracy is sufficiently independent of the available model fitting criteria (including Generalized Cross-validation) that it provides a useful check on the extent of downward bias in the estimated standard error of residual.

Usage

1
2
CVgam(formula, data, nfold = 10, debug.level = 0, method = "GCV.Cp",
              printit = TRUE, cvparts = NULL, gamma = 1, seed = 29)

Arguments

formula

Model formula, for passing to the gam() function

data

data frame that supplies the data

nfold

Number of cross-validation folds

debug.level

See gam for details

method

Fit method for GAM model. See gam for details

printit

Should summary information be printed?

cvparts

Use, if required, to specify the precise folds used for the cross-validation. The comparison between different models will be more accurate if the same folds are used.

gamma

See gam for details.

seed

Set seed, if required, so that results are exactly reproducible

Value

fitted

fitted values

resid

residuals

cvscale

scale parameter from cross-validation

scale.gam

scale parameter from function gam

The scale parameter from cross-validation is the error mean square)

Author(s)

John Maindonald

References

https://maths-people.anu.edu.au/~johnm/nzsr/taws.html

Examples

1
2
3
4
5
6
7
8
if(require(sp)){
library(mgcv)
data(meuse)
meuse$ffreq <- factor(meuse$ffreq)
CVgam(formula=log(zinc)~s(elev) + s(dist) + ffreq + soil,
              data = meuse, nfold = 10, debug.level = 0, method = "GCV.Cp",
              printit = TRUE, cvparts = NULL, gamma = 1, seed = 29)
}

Example output

Loading required package: sp
Loading required package: nlme
This is mgcv 1.8-20. For overview type 'help("mgcv-package")'.
   GAMscale CV-mse-GAM  
     0.1151      0.1307 

gamclass documentation built on Nov. 14, 2020, 1:07 a.m.