# Copyright 2008 Alexander W Blocker # You are free to use, modify, and redistribute this code under the terms of the GNU # General Public License, version 2 # Based on AIC function from GNU R stats package, version 2.6.2 AICc <- function(x, ... , k=2) { UseMethod("AICc"); } AICc.default <- function(x, ... , k=2) { if ( length( list( ... ) ) ) { x <- list( x, ... ); val <- lapply( x, logLik ); val <- as.data.frame( t( sapply( val, function(el) c( attr( el, "df"), AICc( el, k = k) ) ) ) ) names(val) <- c("df", "AICc") row.names(val) <- as.character(match.call()[-1]) return(val) } AICc( logLik( x ) ); } AICc.logLik <- function(x, ... , k=2) { -2 * c(x) + k * attr( x, "df" ) + 2 * attr( x, "df" ) * ( attr( x, "df" ) + 1 )/ ( attr( x, "nobs" ) - attr( x, "df" ) - 1 ); }