[R] Function hatTrace in package lme4

ingaschwabe ingaschwabe at gmail.com
Sat Oct 13 15:31:03 CEST 2012


Dear all, 

For a project I need to calculate the conditional AIC of a mixed effects
model. 
Luckily, I found a reference in the R help forum for a function to be used: 

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) 

        } 

Reference:
http://r.789695.n4.nabble.com/Using-Conditional-AIC-with-lmer-td847899.html

However, in this function the function hatTrace of the lme4 package was used
to calcuate rho 
(line:  rho <- hatTrace(model) )

Sadly, R tells me that this function could not be found. A search on the
internet revealed that this function was dropped out of the new package
release of lme4. 

Can anyone help me with this? Is there an alternative function that gives me
the same result as the hatTrace function? 

I searched the internet for solutions, but I could not find anything that is
helpful. 

Thanks in advance, 

Bye, 
Inga



--
View this message in context: http://r.789695.n4.nabble.com/Function-hatTrace-in-package-lme4-tp4646071.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list