if (FALSE) {
## Derived from example in RLRsim::LRTSim
set.seed(123)
dat <- data.frame(g = rep(1:10, e = 10), x = (x<-rnorm(100)),
y = 0.1 * x + rnorm(100))
m <- fitme(y ~ x + (1|g), data=dat)
m0 <- fitme(y ~ 1, data=dat)
(obs.LRT <- 2*(logLik(m)-logLik(m0)))
args <- get_RLRsim_args(m,m0)
sim.LRT <- do.call(RLRsim::LRTSim, args )
(RLRpval <- (sum(sim.LRT >= obs.LRT) + 1) / (length(sim.LRT) + 1))
## comparable test using LRT():
# (bootpval <- LRT(m,m0, boot.repl = 199L)$rawBootLRT$p_value)
}
Run the code above in your browser using DataLab