R/extractDIC.R

Defines functions extractDIC.merMod extractDIC

Documented in extractDIC extractDIC.merMod

extractDIC <- function(fit,...){
  UseMethod("extractDIC")
}


extractDIC.merMod <- function(fit,...){
        #REML <- fit@dims["REML"]
#        llik <- logLik(fit, REML)
#        dev <- fit@deviance["ML"]
#        n <- fit@dims["n"]
#        Dhat <- -2 * (llik)
#        pD <- dev - Dhat
#        DIC <- dev + pD[[1]]
#        names(DIC) <- "DIC"
#        return(DIC)      
        is_REML <- isREML(fit)
        llik <- logLik(fit, REML=is_REML)
        dev <- deviance(refitML(fit))
        n <-  getME(fit, "devcomp")$dims["n"]
        Dhat <- -2 * (llik)
        pD <- dev - Dhat
        DIC <- dev + pD[[1]]
        names(DIC) <- "DIC"
        return(DIC)
}




#
#extractAIC.mer <- function(fit,...){
##     REML <- fit@dims["REML"]
##    llik <- logLik(fit, REML)
##    AIC <- AIC(llik)
##    names(AIC) <- "AIC"
##    return(AIC)
#    L <- logLik(refitML(fit))
#    edf <- attr(L,"df")
#    out <- c(edf,-2*L + k*edf)
#    return(out)
#} 

Try the arm package in your browser

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

arm documentation built on June 25, 2024, 1:14 a.m.