[R] Using Conditional AIC with lmer

From: Kyle Edwards <kedwards_at_ucdavis.edu>
Date: Thu, 14 Feb 2008 13:08:15 -0800


Hi all,

This was posted originally on r-sig-mixed-models, but I thought I would post here as well as it might be of more general interest.

With a colleague, I have been trying to implement the Conditional AIC described by Vaida and Blanchard 2005 Biometrika, "Conditional Akaike information for mixed-effects models". This quantity is derived in a way analogous to the AIC, but is appropriate for scenarios where one is interested in the particular coefficient estimates for individual random effects. The formula for the asymptotic CAIC is given as

-2*log(likelihood of observed values, conditional on ML estimates of fixed effects and empirical Bayes estimates of random effects) + 2*K

where K = rho + 1, and rho = "effective degrees of freedom" = trace of the hat matrix mapping predicted values onto observed values.

After some thinking and some off-list advice, we have decided that appropriate code for CAIC is

CAIC <- function(model) {

	sigma <- attr(VarCorr(model), 'sc')
	observed <- attr(model, 'y')
	predicted <- fitted(model)	
	cond.loglik <- sum(dnorm(observed, predicted, sigma, log=TRUE))
	
	rho <- hatTrace(model)
	p <- length(fixef(model))
	N <- nrow(attr(model, 'X'))
	K.corr <- N*(N-p-1)*(rho+1)/((N-p)*(N-p-2)) + N*(p+1)/((N-p)*(N-p-2))
	
	CAIC <- -2*cond.loglik + 2*K.corr

	return(CAIC)

	}

where K.corr is the finite-sample correction for K, for ML model fits.

I am posting this so that 1) This code can be of use to any other souls in the statistical wilderness trying to do model selection with mixed models, and 2) So that wiser minds can point out any errors in our approach.

Thanks,

Kyle



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 14 Feb 2008 - 21:13:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Feb 2008 - 21:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive