File: devCritFun.R

package info (click to toggle)
lme4 1.1-38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,808 kB
  • sloc: cpp: 2,543; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
    ## ----------------------------------------------------------------------
}