Learn R Programming

kernDeepStackNet (version 2.0.2)

lossGCV: Generalized cross-validation loss

Description

Calculates the generalized cross-validation score given number of observations, model deviance, effective degrees of freedom and gamma.

Usage

lossGCV(n, Dev, trA, gammaPar=1)

Arguments

n

Number of observations (integer scalar).

Dev

Deviance of the kernel ridge regression (numeric scalar).

trA

Effective degrees of freedom (numeric scalar).

gammaPar

Weighting parameter (numeric scalar), which specifies how the generalized cross-validation score is penalized by the effective degrees of freedom. Default value is 1.

Value

Generalized cross-validation loss (numeric scalar).

References

Simon N. Wood, (2006), Generalized Additive Models: An Introduction with R, Taylor \& Francis Group LLC

See Also

lossApprox, lossCvKDSN, lossSharedCvKDSN, lossSharedTestKDSN

Examples

Run this code
# Simple example based on help pages of mgcv::gam
# GCV Score is the same as used in function mgcv::mgcv
library(mgcv)
dat <- gamSim(1, n=100, dist="normal", scale=2)
gamMod <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
calcGCV <- lossGCV(n=100, Dev=deviance(gamMod), trA=sum(gamMod$edf), gammaPar=1)
all.equal(calcGCV, gamMod$gcv.ubre) # TRUE

Run the code above in your browser using DataLab