R/gcvfun.R

Defines functions gcvfun

Documented in gcvfun

gcvfun <-
  function(x, Xmat, Ymat, nfolds, foldid, ...){
    Bhat <- cmls(X = Xmat, Y = Ymat, const = x$const, 
                 df = x$df, degree = x$degree, 
                 intercept = x$intercept, ...)
    edf <- sum(attr(Bhat, "df"))
    nm <- prod(dim(Ymat))
    top <- mean((Ymat - Xmat %*% Bhat)^2)
    bot <- (1 - edf / nm)^2
    top / bot
  } # end gcvfun.R

Try the CMLS package in your browser

Any scripts or data that you put into this service are public.

CMLS documentation built on April 3, 2023, 5:24 p.m.