Skip to content

Instantly share code, notes, and snippets.

@cheuerde
Last active August 29, 2015 14:05
Show Gist options
  • Save cheuerde/44b3140c4702bb651115 to your computer and use it in GitHub Desktop.
Save cheuerde/44b3140c4702bb651115 to your computer and use it in GitHub Desktop.
AIC / BIC for Asreml #R
'calc' <- function (asreml)
{
summ <- summary(asreml)
vc <- summ$varcomp
DF <- nrow(vc)
if ("Fixed" %in% levels(vc$constraint))
DF <- DF - table(vc$constraint)["Fixed"]
if ("Constrained" %in% levels(vc$constraint))
DF <- DF - table(vc$constraint)["Constrained"]
names(DF) <- ""
logREML <- summ$loglik
AIC <- -2 * logREML + 2 * DF
BIC <- -2 * logREML + DF * log(summ$nedf)
data.frame(DF, AIC, BIC, logREML)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment