tests/devCritFun.R

if (.Platform$OS.type!="windows") {
    library(lme4)

    ## ----------------------------------------------------------------------
    ## test that deviance(REMLfit, REML = FALSE) gives the same answer as
    ## the ML objective function at the REML fit
    ## ----------------------------------------------------------------------
    set.seed(1)
    w <- runif(nrow(sleepstudy))
    fm <- lmer(Reaction ~ Days + (Days | Subject),
               sleepstudy, weights = w)
    dfun <- update(fm, devFunOnly = TRUE, REML = FALSE)
    stopifnot(all.equal(deviance(fm, REML = FALSE),
                        dfun(getME(fm, "theta"))))

    ## ----------------------------------------------------------------------
    ## TODO: test the opposite case that deviance(MLfit, REML = TRUE)
    ## gives the same answer as the REML objective function at the ML fit
    ## ----------------------------------------------------------------------
}

Try the lme4 package in your browser

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

lme4 documentation built on June 22, 2021, 9:07 a.m.