R/infocr.R

Defines functions infocr.lmridge infocr

Documented in infocr infocr.lmridge

infocr <- function(object, ...)
  UseMethod("infocr")

infocr.lmridge <- function(object,...) {
  #AIC for Ridge
  SSER <- apply(resid(object), 2, function(x) {
    sum(x ^ 2)
  })
  df <- rstats2(object)$dfridge
  n <- nrow(object$xs)
  #AIC<-lapply(df, function(x){n*log(SSER)+2*x})
  #rsigma2<-mapply(function(x,y){x/y}, colSums(resid^2), df, SIMPLIFY = FALSE )
  AIC <-
    mapply(function(x,y) {
      n * log(x / n) + 2 * (y)
    }, SSER,df, SIMPLIFY = FALSE)
  AIC <- do.call(cbind, AIC)

  #BIC for Ridge
  #BIC<-lapply(df, function(x){n*log(SSER)+x*log(n)})
  BIC <-
    mapply(function(x,y) {
      n * log(x) + y * log(n)
    }, SSER, df, SIMPLIFY = FALSE)
  BIC <- do.call(cbind, BIC)
  resinfo <- rbind(AIC, BIC)
  rownames(resinfo) <- c("AIC", "BIC")
  t(resinfo)

}

Try the lmridge package in your browser

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

lmridge documentation built on Jan. 15, 2023, 5:06 p.m.