loogam: Leave one out cross-validation on gam or lm object

Description Usage Arguments Value Examples

View source: R/loogam.R

Description

Helper function to do a LOOCV on a gam or lm model

Usage

1
loogam(mod, k = 1, n = 100, LOO = FALSE)

Arguments

mod

A model returned by a gam or lm fit

k

folds. k=1 is LOO, k=2 is LTO

n

samples. How many folds to use.

LOO.

Whether to return the LOO RSME and MdAE for the LOO models. If set to TRUE, function will be slow.

Value

A list with predictions (fitted), actual, errors (fitted-actual), MAE and RMSE. Also AIC and AICc are returned for the LOO models.

Examples

1
2
3
4
5
# some simulated data with one cov
library(mgcv)
dat <- gamSim(6,n=100,scale=.5)[,1:2]
m <- gam(y~s(x0), data=dat)
loogam(m)$MAE

eeholmes/SardineForecast documentation built on July 17, 2021, 2:56 a.m.