Running 'AAAtest-all.R' [42s]
  Running 'HSAURtrees.R' [157s]
  Running 'REMLdev.R' [173s]
  Running 'ST.R' [159s]
  Running 'agridat_gotway.R' [0s]
  Running 'bootMer.R' [153s]
  Running 'boundary.R' [0s]
  Running 'confint.R' [158s]
  Running 'devCritFun.R' [0s]
  Running 'drop.R' [156s]
  Running 'drop1contrasts.R' [0s]
  Running 'dynload.R' [165s]
  Running 'elston.R' [151s]
  Running 'evalCall.R' [160s]
  Running 'extras.R' [2s]
  Running 'falsezero_dorie.R' [0s]
  Running 'fewlevels.R' [174s]
  Running 'getME.R' [0s]
  Running 'glmer-1.R' [169s]
  Running 'glmerControlPass.R' [151s]
  Running 'glmerWarn.R' [0s]
  Running 'glmmExt.R' [2s]
  Running 'glmmWeights.R' [0s]
  Running 'hatvalues.R' [0s]
  Running 'is.R' [0s]
  Running 'lmList-tst.R' [2s]
  Running 'lme4_nlme.R' [2s]
  Running 'lmer-0.R' [152s]
  Running 'lmer-1.R' [2s]
  Comparing 'lmer-1.Rout' to 'lmer-1.Rout.save' ... OK
  Running 'lmer-conv.R' [163s]
  Running 'lmer2_ex.R' [2s]
  Running 'methods.R' [145s]
  Running 'minval.R' [155s]
  Running 'modFormula.R' [153s]
  Running 'nbinom.R' [0s]
  Running 'nlmer-conv.R' [2s]
  Running 'nlmer.R' [170s]
  Running 'offset.R' [2s]
  Running 'optimizer.R' [2s]
  Running 'polytomous.R' [2s]
  Running 'prLogistic.R' [149s]
  Running 'predict_basis.R' [146s]
  Running 'predsim.R' [156s]
  Running 'priorWeights.R' [0s]
  Running 'priorWeightsModComp.R' [169s]
  Running 'profile-tst.R' [2s]
  Running 'refit.R' [2s]
  Running 'resids.R' [156s]
  Running 'respiratory.R' [2s]
  Running 'simulate.R' [159s]
  Running 'test-glmernbref.R' [160s]
  Running 'testOptControl.R' [167s]
  Running 'testcolonizer.R' [2s]
  Running 'testcrab.R' [2s]
  Running 'throw.R' [2s]
  Running 'varcorr.R' [174s]
  Running 'vcov-etc.R' [2s]
Running the tests in 'tests/HSAURtrees.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") withAutoprint({
  +     library("lme4")
  + 
  +     ## example from HSAUR2 package; data from 'multcomp'; see ../inst/testdata/trees513.R
  +     load(system.file("testdata","trees513.RData",package="lme4"))
  + 
  +     ## model formula:
  +     modForm <- damage ~ species - 1 + (1 | lattice / plot)
  + 
  +     dfun <- glmer(modForm, data = trees513B, family = binomial,
  +                   devFunOnly = TRUE)
  +     ls.str(environment(dfun))# "for your information"
  + 
  +     .not.call <- function(x) x[names(x) != "call"]
  + 
  +     if(lme4:::testLevel() < 2) q("no")
  +     ## else  (testLevel >= 2) : --------------------------------------------------
  + 
  +     ## Generate oldres:
  +     ## ----------------
  +     ## library(lme4.0)
  +     ## system.time(mmod0 <- glmer(damage ~ species - 1 + (1 | lattice / plot),
  +     ##               data = trees513, family = binomial()))
  +     ## ## 4 seconds
  +     ## oldres <- c(fixef(mmod0),getME(mmod0,"theta"))
  +     ## detach("package:lme4.0")
  +     ## dput(oldres)
  +     oldres <- structure(c(5.23645064474105, 4.73568475545248, 2.65289926317093,
  +                           1.29043984816924, 1.59329381563025,
  +                           0.532663142106669, 1.16703186884403
  +                           ), .Names = c("speciesspruce", "speciespine",
  +                                         "speciesbeech",
  +                                         "speciesoak", "specieshardwood",
  +                                         "plot:lattice.(Intercept)",
  +                                         "lattice.(Intercept)"))
  +     system.time(mmodA <- glmer(modForm, data = trees513A, family = binomial()))
  +     ## 7 seconds
  +     newres <- c(fixef(mmodA), getME(mmodA,"theta"))
  +     stopifnot(all.equal(oldres, newres, tolerance=1.5e-3))
  +     system.time(mmodB <- glmer(modForm, data = trees513B, family = binomial()))
  +     ## 10.4 seconds
  +     ##
  +     if(FALSE) { ## defuncted in 2019-05 [been deprecated since 2013-06]
  +         ## lmer( + family) -> diverts to glmer() with a warning [TODO: use assertWarning(.) eventually]
  +         system.time(lmodB <-
  +                         lmer(modForm, data = trees513B, family = binomial()))
  +         stopifnot(all.equal(.not.call(summary(mmodB)),
  +                             .not.call(summary(lmodB))))
  +         newresB <- c(fixef(mmodB),getME(mmodB,"theta"))
  +         stopifnot(length(newresB) == length(oldres) + 1)# extra: species[ash/maple/elm/lime]
  +     }
  + 
  + 
  + }) ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.18    0.06    0.23 
Running the tests in 'tests/REMLdev.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > ## show important current settings {for reference, etc} -- [early, and also on Windows !]:
  > str( lmerControl())
  List of 8
   $ optimizer      : chr "nloptwrap"
   $ restart_edge   : logi TRUE
   $ boundary.tol   : num 1e-05
   $ calc.derivs    : logi TRUE
   $ use.last.params: logi FALSE
   $ checkControl   :List of 8
    ..$ check.nobs.vs.rankZ: chr "ignore"
    ..$ check.nobs.vs.nlev : chr "stop"
    ..$ check.nlev.gtreq.5 : chr "ignore"
    ..$ check.nlev.gtr.1   : chr "stop"
    ..$ check.nobs.vs.nRE  : chr "stop"
    ..$ check.rankX        : chr "message+drop.cols"
    ..$ check.scaleX       : chr "warning"
    ..$ check.formula.LHS  : chr "stop"
   $ checkConv      :List of 3
    ..$ check.conv.grad    :List of 3
    .. ..$ action: chr "warning"
    .. ..$ tol   : num 0.002
    .. ..$ relTol: NULL
    ..$ check.conv.singular:List of 2
    .. ..$ action: chr "message"
    .. ..$ tol   : num 1e-04
    ..$ check.conv.hess    :List of 2
    .. ..$ action: chr "warning"
    .. ..$ tol   : num 1e-06
   $ optCtrl        : list()
   - attr(*, "class")= chr [1:2] "lmerControl" "merControl"
  > str(glmerControl())
  List of 11
   $ optimizer      : chr [1:2] "bobyqa" "Nelder_Mead"
   $ restart_edge   : logi FALSE
   $ boundary.tol   : num 1e-05
   $ calc.derivs    : logi TRUE
   $ use.last.params: logi FALSE
   $ checkControl   :List of 9
    ..$ check.nobs.vs.rankZ     : chr "ignore"
    ..$ check.nobs.vs.nlev      : chr "stop"
    ..$ check.nlev.gtreq.5      : chr "ignore"
    ..$ check.nlev.gtr.1        : chr "stop"
    ..$ check.nobs.vs.nRE       : chr "stop"
    ..$ check.rankX             : chr "message+drop.cols"
    ..$ check.scaleX            : chr "warning"
    ..$ check.formula.LHS       : chr "stop"
    ..$ check.response.not.const: chr "stop"
   $ checkConv      :List of 3
    ..$ check.conv.grad    :List of 3
    .. ..$ action: chr "warning"
    .. ..$ tol   : num 0.002
    .. ..$ relTol: NULL
    ..$ check.conv.singular:List of 2
    .. ..$ action: chr "message"
    .. ..$ tol   : num 1e-04
    ..$ check.conv.hess    :List of 2
    .. ..$ action: chr "warning"
    .. ..$ tol   : num 1e-06
   $ optCtrl        : list()
   $ tolPwrss       : num 1e-07
   $ compDev        : logi TRUE
   $ nAGQ0initStep  : logi TRUE
   - attr(*, "class")= chr [1:2] "glmerControl" "merControl"
  > str(nlmerControl())
  List of 3
   $ optimizer: chr [1:2] "Nelder_Mead" "Nelder_Mead"
   $ tolPwrss : num 1e-10
   $ optCtrl  : list()
   - attr(*, "class")= chr [1:2] "nlmerControl" "merControl"
  > ls.str(environment(nloptwrap))
  defaultControl : List of 4
   $ algorithm: chr "NLOPT_LN_BOBYQA"
   $ xtol_abs : num 1e-08
   $ ftol_abs : num 1e-08
   $ maxeval  : num 1e+05
  > ##
  > fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  > fm1ML <- refitML(fm1)
  > REMLcrit(fm1)
  [1] 1743.628
  > deviance(fm1ML)
  [1] 1751.939
  > deviance(fm1,REML=FALSE)  ## FIXME: not working yet (NA)
  [1] 1751.986
  > deviance(fm1,REML=TRUE)
  [1] 1751.986
  > 
  > ## from lme4.0
  > oldvals <- c(REML=1743.6282722424, ML=1751.98581103058)
  > ## leave out ML values for REML fits for now ...
  > stopifnot(
  +           all.equal(REMLcrit(fm1),deviance(fm1,REML=TRUE),deviance(fm1ML,REML=TRUE),oldvals["REML"]),
  +           all.equal(deviance(fm1ML),deviance(fm1ML,REML=FALSE),oldvals["ML"]),
  +           all.equal(REMLcrit(fm1)/-2,c(logLik(fm1)),c(logLik(fm1ML,REML=TRUE)),c(logLik(fm1,REML=TRUE))),
  +           all.equal(deviance(fm1ML)/-2,c(logLik(fm1ML,REML=FALSE)),
  +                     c(logLik(fm1ML,REML=FALSE))))
  > 
  > ## should be:
  > ## stopifnot(
  > ##           all.equal(deviance(fm1),deviance(fm1,REML=TRUE),deviance(fm1ML,REML=TRUE),oldvals["REML"]),
  > ##           all.equal(deviance(fm1ML),deviance(fm1,REML=FALSE),deviance(fm1ML,REML=FALSE),oldvals["ML"]),
  > ##           all.equal(deviance(fm1)/2,c(logLik(fm1)),c(logLik(fm1ML,REML=TRUE)),c(logLik(fm1,REML=TRUE))),
  > ##           all.equal(deviance(fm1ML)/2,c(logLik(fm1,REML=FALSE)),c(logLik(fm1ML,REML=FALSE)),
  > ##                     c(logLik(fm1ML,REML=FALSE))))
  > 
  > proc.time()
     user  system elapsed 
     1.78    0.21    1.98 
Running the tests in 'tests/ST.R' failed.
Complete output:
  > require(lme4)
  Loading required package: lme4
  Loading required package: Matrix
  > # sorry for fitting yet another sleepstudy model in the tests
  > m <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
  > ST <- getME(m, "ST")$Subject
  > 
  > # copied from vince dorie's simmer.R in arm:
  > dimension <- nrow(ST)
  > T <- ST
  > diag(T) <- rep(1, dimension)
  > S <- diag(diag(ST), dimension)
  > 
  > vc0 <- getME(m, 'sigma')^2*tcrossprod(T %*% S)
  > vc1 <- VarCorr(m)$Subject[,]
  > dimnames(vc0) <- dimnames(vc1)
  > 
  > all.equal(vc0, vc1, tolerance = 1e-6)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     1.53    0.20    1.73 
Running the tests in 'tests/bootMer.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") {
  + 
  +     library(lme4)
  + 
  +     mySumm <- function(.) {
  +         s <- sigma(.)
  +         c(beta =getME(., "beta"),
  +           sigma = s,
  +           sig01 = unname(s * getME(., "theta")))
  +     }
  + 
  +     fm1 <- lmer(Yield ~ 1|Batch, Dyestuff)
  +     boo01 <- bootMer(fm1, mySumm, nsim = 10)
  +     boo02 <- bootMer(fm1, mySumm, nsim = 10, use.u = TRUE)
  + 
  +     ## boo02 <- bootMer(fm1, mySumm, nsim = 500, use.u = TRUE)
  +     if (require(boot)) {
  +         boot.ci(boo02,index=2,type="perc")
  +     }
  + 
  +     fm2 <- lmer(angle ~ recipe * temperature + (1|recipe:replicate), cake)
  +     boo03 <- bootMer(fm2, mySumm, nsim = 10)
  +     boo04 <- bootMer(fm2, mySumm, nsim = 10, use.u = TRUE)
  + 
  +     if (lme4:::testLevel() > 1) {
  +         gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                      data = cbpp, family = binomial)
  +         boo05 <- bootMer(gm1, mySumm, nsim = 10)
  +         boo06 <- bootMer(gm1, mySumm, nsim = 10, use.u = TRUE)
  + 
  +         cbpp$obs <- factor(seq(nrow(cbpp)))
  +         gm2 <- glmer(cbind(incidence, size - incidence) ~ period +
  +                          (1 | herd) +  (1|obs),
  +                      family = binomial, data = cbpp)
  +         boo03 <- bootMer(gm2, mySumm, nsim = 10)
  +         boo04 <- bootMer(gm2, mySumm, nsim = 10, use.u = TRUE)
  +     }
  +     load(system.file("testdata","culcita_dat.RData",package="lme4"))
  +     cmod <- glmer(predation~ttt+(1|block),family=binomial,data=culcita_dat)
  +     set.seed(101)
  +     ## FIXME: sensitive to step-halving PIRLS tests
  +     ## expect_warning(cc <- confint(cmod,method="boot",nsim=10,quiet=TRUE,
  +     ##              .progress="txt",PBargs=list(style=3)),"some bootstrap runs failed")
  + 
  + 
  +     library(parallel)
  +     if (detectCores()>1) {
  +         ## http://stackoverflow.com/questions/12983137/how-do-detect-if-travis-ci-or-not
  +         travis <- nchar(Sys.getenv("TRAVIS"))>0
  +         if(.Platform$OS.type != "windows" && !travis) {
  +             boo01P <- bootMer(fm1, mySumm, nsim = 10, parallel="multicore", ncpus=2)
  +         }
  + 
  +         ## works in Solaris from an interactive console but not ???
  +         ##   via R CMD BATCH
  +         if (Sys.info()["sysname"] != "SunOS")
  +             boo01P.snow <- bootMer(fm1, mySumm, nsim = 10, parallel="snow", ncpus=2)
  +     }
  + 
  +     set.seed(101)
  +     dd <- data.frame(x=runif(200),
  +                      f=rep(1:20,each=10),
  +                      o=rnorm(200,mean=2))
  +     dd$y <- suppressMessages(simulate(~x+(1|f)+offset(o),
  +                                       family="poisson",
  +                                       newdata=dd,
  +                                       newparams=list(theta=1,beta=c(0,2)))[[1]])
  + 
  +     ## fails under flexLambda
  +     dd$y2 <- suppressMessages(simulate(~x+(1|f)+offset(o),
  +                                        family="gaussian",
  +                                        newdata=dd,
  +                                        newparams=list(theta=1,beta=c(0,2),sigma=1))[[1]])
  + 
  +     fm3 <- glmer(y~x+(1|f)+offset(o),
  +                  data=dd,family="poisson")
  + 
  +     fm4 <- lmer(y2~x+(1|f)+offset(o),
  +                 data=dd)
  + 
  +     mySumm2 <- function(fit) return(c(fixef(fit),getME(fit,'theta')))
  +     ## still some issues to fix here
  +     bb <- bootMer(fm3,mySumm2,nsim=10)
  +     attr(bb,"boot.fail.msgs")
  +     bb2 <- bootMer(fm4,mySumm2,nsim=10)
  + 
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.14    0.03    0.15 
Running the tests in 'tests/confint.R' failed.
Complete output:
  > if (lme4:::testLevel() > 1 || .Platform$OS.type != "windows") withAutoprint({
  +     library("lme4")
  +     library("testthat")
  + 
  +     L <- load(system.file("testdata", "lme-tst-fits.rda",
  +                           package="lme4", mustWork=TRUE))
  +     ## -> "fit_*" objects
  + 
  +     fm1 <- fit_sleepstudy_2
  +     c0  <- confint(fm1, method="Wald")
  +     c0B <- confint(fm1, method="Wald",parm="Days")
  +     expect_equal(c0["Days",],c0B["Days",])
  +     expect_equal(c(c0B),c(7.437592,13.496980),tolerance=1e-6)
  +     set.seed(101)
  + 
  +     for (bt in c("norm", "basic", "perc")) {
  +         suppressWarnings(
  +             confint(fm1, method="boot", boot.type=bt, nsim=10,quiet=TRUE))
  +     }
  +     for (bt in c("stud","bca","junk")) {
  +         expect_error(confint(fm1, method="boot", boot.type=bt, nsim=10),
  +                      "should be one of")
  +     }
  +     if((testLevel <- lme4:::testLevel()) > 1) {
  +         pr1.56 <- profile(fm1, which = 5:6)
  +         c1 <- confint(pr1.56, method="profile")
  +         expect_equal(c0[5:6,],c1,tolerance=2e-3)  ## expect Wald and profile _reasonably_ close
  +         print(c1,digits=3)
  +         ##
  +         c6 <- confint(pr1.56, "Days")
  +         expect_equal(c1[2, , drop=FALSE], c6)
  +         c2  <- confint(fm1,method="boot",nsim=50,parm=5:6)
  +         ## expect_error(confint(fm1,method="boot",nsim=50,parm="Days"),
  +         ##  "must be specified as an integer")
  +         expect_equal(c1,c2,tolerance=2e-2)
  +         print(c2,digits=3)
  +     }
  +     if (testLevel > 10) {
  +         print(c1B <- confint(fm1, method="profile"))
  +         print(c2B <- confint(fm1, method="boot"))
  +         expect_equal(unname(c1B), unname(c2B), tolerance=2e-2)
  +     }
  + }) ## skip if windows/testLevel<1
  > 
  > proc.time()
     user  system elapsed 
     1.43    0.17    1.60 
Running the tests in 'tests/drop.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") withAutoprint({
  +     library(lme4)
  + 
  +     fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  + 
  +     ## slightly weird model but plausible --- not that
  +     ##   one would want to try drop1() on this model ...
  +     fm2 <- lmer(Reaction ~ 1+ (Days|Subject), sleepstudy)
  +     drop1(fm2)  ## empty
  +     update(fm1, . ~ . - Days)
  +     anova(fm2) ## empty
  + 
  +     terms(fm1)
  +     terms(fm1,fixed.only=FALSE)
  + 
  +     extractAIC(fm1)
  + 
  +     drop1(fm1)
  +     drop1(fm1, test="Chisq")
  + 
  +     gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                  family = binomial, data = cbpp, nAGQ=25L)
  + 
  +     drop1(gm1, test="Chisq")
  + 
  + }) ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.15    0.12    0.21 
Running the tests in 'tests/dynload.R' failed.
Complete output:
  > ## this is the simpler version of the code for testing/exercising
  > ## https://github.com/lme4/lme4/issues/35
  > ## see also ../misc/issues/dynload.R for more complexity
  > pkg <- so_name <- "lme4"; doUnload <- FALSE; doTest <- TRUE
  > ## pkg <- so_name <- "RcppEigen"; doUnload <- TRUE; doTest <- TRUE
  > ## need to deal with the fact that DLL name != package name for lme4.0 ...
  > ### pkg <- "lme4.0"; so_name <- "lme4"; doUnload <- TRUE
  > instPkgs <- as.data.frame(installed.packages(),stringsAsFactors=FALSE)
  > Load <- function() {
  +     library(pkg,character.only=TRUE)
  + }
  > Unload <- function() {
  +     ld <- library.dynam()
  +     pnames <- sapply(ld,"[[","name")
  +     names(ld) <- pnames
  +     lp <- gsub("/libs/.*$","",ld[[so_name]][["path"]])
  +     cat("unloading from",lp,"\n")
  +     library.dynam.unload(so_name, lp)
  + }
  > Detach <- function() {
  +     detach(paste0("package:",pkg),character.only=TRUE,unload=TRUE)
  +     if (doUnload) Unload()
  + }
  > tmpf <- function() {
  +     g <- getLoadedDLLs()
  +     lnames <- names(g)[is.na(instPkgs[names(g),"Priority"])]
  +     cat("loaded DLLs:",lnames,"\n")
  +     g <- g[na.omit(match(c(so_name,"nlme"),names(g)))]
  +     class(g) <- "DLLInfoList"
  +     g
  + }
  > test <- function() {
  +     if (doTest) {
  +         if (pkg %in% c("lme4","lme4.0")) {
  +             fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy,
  +                         devFunOnly=TRUE)
  +         }
  +         if (pkg=="RcppEigen") {
  +             data(trees, package="datasets")
  +             mm <- cbind(1, log(trees$Girth))   # model matrix
  +             y  <- log(trees$Volume)            # response
  +             ## bare-bones direct interface
  +             flm <- fastLmPure(mm, y)
  +         }
  +     }
  + }
  > if (FALSE) {
  +   ## FIXME: disabled test for now
  + for (i in 1:6) {
  +     cat("Attempt #",i,"\n",sep="")
  +     cat("loading",pkg,"\n")
  +     Load()
  +     tmpf()
  +     test()
  +     cat("detaching",pkg,"\n")
  +     Detach()
  +     cat("loading nlme\n")
  +     library("nlme")
  +     tmpf()
  +     detach("package:nlme",unload=TRUE)
  +     cat("detaching nlme\n")
  + }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.17    0.32 
Running the tests in 'tests/elston.R' failed.
Complete output:
  > ## original code for reading/aggregating:
  > 
  > ## tickdata <- read.table("Elston2001_tickdata.txt",header=TRUE,
  > ##   colClasses=c("factor","numeric","factor","numeric","factor","factor"))
  > 
  > ## tickdata <- transform(tickdata,cHEIGHT=scale(HEIGHT,scale=FALSE))
  > ## for (i in names(tickdata)) {
  > ##   if (is.factor(tickdata[[i]])) {
  > ##     tickdata[[i]] <- factor(tickdata[[i]],levels=sort(as.numeric(levels(tickdata[[i]]))))
  > ##   }
  > ## }
  > ## summary(tickdata)
  > ## grouseticks <- tickdata
  > 
  > ## library(reshape)
  > ## meantick <- rename(aggregate(TICKS~BROOD,data=tickdata,FUN=mean),
  > ##                    c(TICKS="meanTICKS"))
  > ## vartick <- rename(aggregate(TICKS~BROOD,data=tickdata,FUN=var),
  > ##                    c(TICKS="varTICKS"))
  > ## uniqtick <- unique(subset(tickdata,select=-c(INDEX,TICKS)))
  > ## grouseticks_agg <- Reduce(merge,list(meantick,vartick,uniqtick))
  > 
  > ## save("grouseticks","grouseticks_agg",file="grouseticks.rda")
  > if (.Platform$OS.type != "windows") {
  +     library(lme4)
  +     data(grouseticks)
  +     do.plots <- FALSE
  +     form <- TICKS~YEAR+HEIGHT+(1|BROOD)+(1|INDEX)+(1|LOCATION)
  + 
  +     ## fit with lme4
  +     ## library(lme4)
  +     ## t1 <- system.time(full_mod1  <- glmer(form, family="poisson",data=grouseticks))
  +     ## c1 <- c(fixef(full_mod1),unlist(VarCorr(full_mod1)), logLik=logLik(full_mod1),time=t1["elapsed"])
  +     ## allcoefs1 <- c(unlist(full_mod1@ST),fixef(full_mod1))
  +     ## detach("package:lme4")
  + 
  +     ## lme4 summary results:
  +     t1 <- structure(c(1.288, 0.048, 1.36, 0, 0), class = "proc_time",
  +                     .Names = c("user.self",
  +                                "sys.self", "elapsed", "user.child", "sys.child"))
  + 
  +     c1 <- structure(c(11.3559080756861, 1.1804105508475, -0.978704335712111,
  +                       -0.0237607330254979, 0.293232458048324, 0.562551624933584,
  +                       0.279548178949372,
  +                       -424.771990224991, 1.36),
  +                     .Names = c("(Intercept)", "YEAR96",
  +                                "YEAR97", "HEIGHT", "INDEX", "BROOD", "LOCATION",
  +                                "logLik", "time.elapsed"
  +                                ))
  +     allcoefs1 <- structure(c(0.541509425632023, 0.750034415832756,
  +                              0.528723159081737,
  +                              11.3559080756861, 1.1804105508475,
  +                              -0.978704335712111, -0.0237607330254979
  +                              ),
  +                            .Names = c("", "", "", "(Intercept)",
  +                                       "YEAR96", "YEAR97",  "HEIGHT"))
  + 
  +     pars <- function(x) unlist(getME(x,c("theta","beta")))
  + 
  +     if (lme4:::testLevel() > 1) {
  +         t2 <- system.time(full_mod2  <- glmer(form, family="poisson",data=grouseticks))
  +         ##>> 2 x checkConv(.. "derivs") warning: 1. failed to conv.  2. nearly unidentifiable
  +         c2 <- c(fixef(full_mod2), unlist(VarCorr(full_mod2)),
  +                 logLik = logLik(full_mod2), time= t2["elapsed"])
  +         ## refit
  +         ## FIXME: eventually would like to get _exactly_ identical answers on refit()
  +         full_mod3 <- refit(full_mod2, grouseticks$TICKS)
  + 
  +         print(    all.equal(pars(full_mod2), pars(full_mod3), tolerance=0))# -> 1.2e-5
  +         stopifnot(all.equal(pars(full_mod2), pars(full_mod3), tolerance=8e-5))
  +     }
  + 
  +     ## deviance function
  +     ## FIXME: does compDev do _anything_ any more?
  +     mm  <- glmer(form, family="poisson", data=grouseticks, devFunOnly=TRUE)
  +     mm2 <- glmer(form, family="poisson", data=grouseticks,
  +                  devFunOnly=TRUE,control=glmerControl(compDev=TRUE))
  +     stopifnot(all.equal(1780.5427072, mm(allcoefs1), tol = 1e-7))
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.15    0.07    0.20 
Running the tests in 'tests/evalCall.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") {
  +     ## see if we can still run lme4 functions when lme4 is not attached
  +     if ("package:lme4" %in% search()) detach("package:lme4")
  +     data(sleepstudy,package="lme4")
  +     data(cbpp,package="lme4")
  +     fm1 <- lme4::lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  +     gm1 <- lme4::glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                        data = cbpp, family = binomial)
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.14    0.07    0.20 
Running the tests in 'tests/fewlevels.R' failed.
Complete output:
  > #### example originally from Gabor Grothendieck
  > 
  > source(system.file("testdata/lme-tst-funs.R", package="lme4", mustWork=TRUE))
  > ##--> rSim.11()
  > testLevel <- if (nzchar(s <- Sys.getenv("LME4_TEST_LEVEL"))) as.numeric(s) else 1
  > 
  > if (testLevel>1) {
  + set.seed(1)
  + d1 <- rSim.11(10000, k=4)
  + library(nlme)
  + m.lme <- lme(y ~ x, random=~ 1|fac , data=d1)
  + (VC.lme <- VarCorr(m.lme))
  + detach("package:nlme")
  + ##
  + library(lme4)
  + fm.NM <- lmer(y ~ x + (1|fac), data=d1, control=lmerControl("Nelder_Mead"))
  + fm.Bq <- update(fm.NM, control=lmerControl("bobyqa"))
  + v.lmer <- VarCorr(fm.NM)[[1]][1,1]
  + stopifnot(all.equal(v.lmer,19.55,tolerance=1e-3))
  + ## was 19.5482 with old starting values (1), 19.5493 with new start algorithm
  + } ## testLevel>1
  > 
  > proc.time()
     user  system elapsed 
     0.18    0.09    0.20 
Running the tests in 'tests/glmer-1.R' failed.
Complete output:
  > if (lme4:::testLevel() > 1 || .Platform$OS.type!="windows") withAutoprint({
  + 
  +     ## generalized linear mixed model
  +     stopifnot(suppressPackageStartupMessages(require(lme4)))
  +     options(show.signif.stars = FALSE)
  + 
  +     source(system.file("test-tools-1.R", package = "Matrix"), keep.source = FALSE)
  +     ##
  +     ##' Check that coefficient +- "2" * SD  contains true value
  +     ##'
  +     ##' @title Check that confidence interval for coefficients contains true value
  +     ##' @param fm fitted model, e.g., from  lm(), lmer(), glmer(), ..
  +     ##' @param true.coef numeric vector of true (fixed effect) coefficients
  +     ##' @param conf.level confidence level for confidence interval
  +     ##' @param sd.factor the "2", i.e. default 1.96 factor for the confidence interval
  +     ##' @return TRUE or a string of "error"
  +     ##' @author Martin Maechler
  +     chkFixed <- function(fm, true.coef, conf.level = 0.95,
  +                          sd.factor = qnorm((1+conf.level)/2))
  +     {
  +         stopifnot(is.matrix(cf <- coefficients(summary(fm))), ncol(cf) >= 2)
  +         cc <- cf[,1]
  +         sd <- cf[,2]
  +         if(any(out1 <- true.coef < cc - sd.factor*sd))
  +             return(sprintf("true coefficient[j], j=%s, is smaller than lower confidence limit",
  +                            paste(which(out1), collapse=", ")))
  +         if(any(out2 <- true.coef > cc + sd.factor*sd))
  +             return(sprintf("true coefficient[j], j=%s, is larger than upper confidence limit",
  +                            paste(which(out2), collapse=", ")))
  +         ## else, return
  +         TRUE
  +     }
  + 
  + 
  +     ## TODO: (1) move these to ./glmer-ex.R [DONE]
  +     ## ----  (2) "rationalize" with ../man/cbpp.Rd
  +                                         #m1e <- glmer1(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                                         #              family = binomial, data = cbpp, doFit = FALSE)
  +     ## now
  +                                         #bobyqa(m1e, control = list(iprint = 2L))
  + 
  +     m1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                 family = binomial, data = cbpp)
  +     m1. <- update(m1, start = getME(m1, c("theta", "fixef")))
  +     dm1 <- drop1(m1)
  +     stopifnot(all.equal(drop1(m1.), dm1, tol = 1e-10))# Lnx(F28) 64b: 4e-12
  +     ## response as a vector of probabilities and usage of argument "weights"
  +     m1p <- glmer(incidence / size ~ period + (1 | herd), weights = size,
  +                  family = binomial, data = cbpp)
  +     ## Confirm that these are equivalent:
  +     stopifnot(all.equal(fixef(m1), fixef(m1p)),
  +               all.equal(ranef(m1), ranef(m1p)),
  +               TRUE)
  +     ## for(m in c(m1, m1p)) {
  +     ##     cat("-------\\n\\nCall: ",
  +     ##         paste(format(getCall(m)), collapse="\\n"), "\\n")
  +     ##     print(logLik(m)); cat("AIC:", AIC(m), "\\n") ; cat("BIC:", BIC(m),"\\n")
  +     ## }
  +     stopifnot(all.equal(logLik(m1), logLik(m1p)),
  +               all.equal(AIC(m1),    AIC(m1p)),
  +               all.equal(BIC(m1),    BIC(m1p)))
  + 
  + 
  +     ## changed tolPwrss to 1e-7 to match other default
  +     m1b <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                  family = binomial, data = cbpp, verbose = 2L,
  +                  control =
  +                      glmerControl(optimizer="bobyqa", tolPwrss=1e-7,
  +                                   optCtrl=list(rhobeg=0.2, rhoend=2e-7)))
  + 
  +     ## using nAGQ=9L provides a better evaluation of the deviance
  +     m.9 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                  family = binomial, data = cbpp, nAGQ = 9)
  + 
  +     ## check with nAGQ = 25
  +     m2 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +                 family = binomial, data = cbpp, nAGQ = 25)
  + 
  +     ## loosened tolerance on parameters
  +     stopifnot(is((cm2 <- coef(m2)), "coef.mer"),
  +               dim(cm2$herd) == c(15,4),
  +               all.equal(fixef(m2),
  + ### lme4a [from an Ubuntu 11.10 amd64 system]
  +                         c(-1.39922533406847, -0.991407294757321,
  +                           -1.12782184600404, -1.57946627431248),
  +                         ##c(-1.3766013, -1.0058773,
  +                         ##  -1.1430128, -1.5922817),
  +                         tolerance = 5.e-4,
  +                         check.attributes=FALSE),
  +               all.equal(c(-2*logLik(m2)), 100.010030538022, tolerance=1e-9),
  +               all.equal(deviance(m2), 73.373, tolerance=1e-5)
  +               ## with bobyqa first (AGQ=0), then
  +               ##all.equal(deviance(m2), 101.119749563, tolerance=1e-9)
  +               )
  + 
  +     ## 32-bit Ubuntu 10.04:
  +     coef_m1_lme4.0 <- structure(c(-1.39853505102576,
  +                                   -0.992334712470269, -1.12867541092127,
  +                                   -1.58037389566025),
  +                                 .Names = c("(Intercept)", "period2", "period3",
  +                                            "period4"))
  + 
  +     ## library(glmmADMB)
  +     ## mg <- glmmadmb(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +     ##                family = "binomial", data = cbpp)
  +     coef_m1_glmmadmb <- structure(c(-1.39853810064827, -0.99233330126975, -1.12867317840779,
  +                                     -1.58031150854503), .Names = c("(Intercept)", "period2", "period3",
  +                                                                    "period4"))
  + 
  +     ## library(glmmML)
  +     ## mm <- glmmML(cbind(incidence, size - incidence) ~ period,
  +     ##              cluster=herd,
  +     ##             family = "binomial", data = cbpp)
  +     coef_m1_glmmML <- structure(c(-1.39853234657711, -0.992336901732793, -1.12867036466201,
  +                                   -1.58030977686564), .Names = c("(Intercept)", "period2", "period3",
  +                                                                  "period4"))
  + 
  +     ## lme4[r 1636], 64-bit ubuntu 11.10:
  +     ## c(-1.3788385, -1.0589543,
  +     ##                      -1.1936382, -1.6306271),
  + 
  +     stopifnot(is((cm1 <- coef(m1b)), "coef.mer"),
  +               dim(cm1$herd) == c(15,4),
  +               all.equal(fixef(m1b),fixef(m1),tolerance=4e-5),
  +               is.all.equal4(fixef(m1b),
  +                             coef_m1_glmmadmb,
  +                             coef_m1_lme4.0,
  +                             coef_m1_glmmML,
  +                             tol = 5e-4)
  +               )
  + 
  + 
  +     ## Deviance for the new algorithm is lower, eventually we should change the previous test
  +     ##stopifnot(deviance(m1) <= deviance(m1e))
  + 
  +     showProc.time() #
  + 
  +     if (require('MASS', quietly = TRUE)) {
  +         bacteria$wk2 <- bacteria$week > 2
  +         contrasts(bacteria$trt) <-
  +             structure(contr.sdif(3),
  +                       dimnames = list(NULL, c("diag", "encourage")))
  +         print(fm5 <- glmer(y ~ trt + wk2 + (1|ID),
  +                            data=bacteria, family=binomial))
  +         showProc.time() #
  + 
  +         stopifnot(
  +             all.equal(logLik(fm5),
  +                       ## was	  -96.127838
  +                       structure(-96.13069, nobs = 220L, nall = 220L,
  +                                 df = 5L, REML = FALSE,
  +                                 class = "logLik"),
  +                       tolerance = 5e-4, check.attributes = FALSE)
  +            ,
  +             all.equal(fixef(fm5),
  +                       ## was		 2.834218798		 -1.367099481
  +                       c("(Intercept)"= 2.831609490, "trtdiag"= -1.366722631,
  +                         ## now	 0.5842291915,		 -1.599148773
  +                         "trtencourage"=0.5840147802, "wk2TRUE"=-1.598591346),
  +                       tolerance = 1e-4 )
  +         )
  +     }
  + 
  +     ## Failure to specify a random effects term - used to give an obscure message
  +     ## Ensure *NON*-translated message; works on Linux,... :
  +     if(.Platform$OS.type == "unix") {
  +         Sys.setlocale("LC_MESSAGES", "C")
  +         tc <- tryCatch(
  +             m2 <- glmer(incidence / size ~ period, weights = size,
  +                         family = binomial, data = cbpp)
  +           , error = function(.) .)
  +         stopifnot(inherits(tc, "error"),
  +                   identical(tc$message,
  +                             "No random effects terms specified in formula"))
  +     }
  + 
  + 
  +     ## glmer - Modeling overdispersion as "mixture" aka
  +     ## ----- - *ONE* random effect *PER OBSERVATION" -- example inspired by Ben Bolker:
  + 
  +     ##' <description>
  +     ##'
  +     ##' <details>
  +     ##' @title
  +     ##' @param ng number of groups
  +     ##' @param nr number of "runs", i.e., observations per groups
  +     ##' @param sd standard deviations of group and "Individual" random effects,
  +     ##'    (\sigma_f, \sigma_I)
  +     ##' @param b  true beta (fixed effects)
  +     ##' @return a data frame (to be used in glmer()) with columns
  +     ##'    (x, f, obs, eta0, eta, mu, y), where y ~ Pois(lambda(x)),
  +     ##'                                   log(lambda(x_i)) = b_1 + b_2 * x + G_{f(i)} + I_i
  +     ##'    and G_k ~ N(0, \sigma_f);  I_i ~ N(0, \sigma_I)
  +     ##' @author Ben Bolker and Martin Maechler
  +     rPoisGLMMi <- function(ng, nr, sd=c(f = 1, ind = 0.5), b=c(1,2))
  +     {
  +         stopifnot(nr >= 1, ng >= 1,
  +                   is.numeric(sd), names(sd) %in% c("f","ind"), sd >= 0)
  +         ntot <- nr*ng
  +         b.reff <- rnorm(ng,  sd= sd[["f"]])
  +         b.rind <- rnorm(ntot,sd= sd[["ind"]])
  +         x <- runif(ntot)
  +         within(data.frame(x,
  +                           f = factor(rep(LETTERS[1:ng], each=nr)),
  +                           obs = 1:ntot,
  +                           eta0 = cbind(1, x) %*% b),
  +         {
  +             eta <- eta0 + b.reff[f] + b.rind[obs]
  +             mu <- exp(eta)
  +             y <- rpois(ntot, lambda=mu)
  +         })
  +     }
  + 
  +     set.seed(1)
  +     dd <- rPoisGLMMi(12, 20)
  +     m0  <- glmer(y~x + (1|f),           family="poisson", data=dd)
  +     m1 <- glmer(y~x + (1|f) + (1|obs), family="poisson", data=dd)
  +     stopifnot(isTRUE(chkFixed(m0, true.coef = c(1,2))),
  +               isTRUE(chkFixed(m1, true.coef = c(1,2))))
  +     (a01 <- anova(m0, m1))
  + 
  +     stopifnot(all.equal(a01$Chisq[2], 554.334056, tolerance=1e-5),
  +               all.equal(a01$logLik, c(-1073.77193, -796.604902), tolerance=1e-6),
  +               a01$ npar == 3:4,
  +               na.omit(a01$ Df) == 1)
  + 
  +     if(lme4:::testLevel() > 1) {
  +         nsim <- 10
  +         set.seed(2)
  +         system.time(
  +             simR <- lapply(1:nsim,  function(i) {
  +                 cat(i,"", if(i %% 20 == 0)"\n")
  +                 dd <- rPoisGLMMi(10 + rpois(1, lambda=3),
  +                                  16 + rpois(1, lambda=5))
  +                 m0 <- glmer(y~x + (1|f),           family="poisson", data=dd)
  +                 m1 <- glmer(y~x + (1|f) + (1|obs), family="poisson", data=dd)
  +                 a01 <- anova(m0, m1)
  +                 stopifnot(a01$ npar == 3:4,
  +                           na.omit(a01$ Df) == 1)
  +                 list(chk0 = chkFixed(m0, true.coef = c(1,2)),
  +                      chk1 = chkFixed(m1, true.coef = c(1,2)),
  +                      chisq= a01$Chisq[2],
  +                      lLik = a01$logLik)
  +             }))
  + 
  +         ## m0 is the wrong model, so we don't expect much here:
  +         table(unlist(lapply(simR, `[[`, "chk0")))
  + 
  + 
  +         ## If the fixed effect estimates were unbiased and the standard errors correct,
  +         ## and N(0,sigma^2) instead of t_{nu} good enough for the fixed effects,
  +         ## the confidence interval should contain the true coef in ~95 out of 100:
  +         table(unlist(lapply(simR, `[[`, "chk1")))
  + 
  +         ## The tests are all highly significantly in favor of  m1 :
  +         summary(chi2s <- sapply(simR, `[[`, "chisq"))
  +         ##  Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  +         ## 158.9   439.0   611.4   698.2   864.3  2268.0
  +         stopifnot(chi2s > qchisq(0.9999, df = 1))
  +     }
  + 
  +     showProc.time()
  + })  ## skip if windows and testLevel<1
  > 
  > proc.time()
     user  system elapsed 
     1.57    0.14    1.70 
Running the tests in 'tests/glmerControlPass.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") {
  +     ## test redirection from lmer to glmer (correct options passed,
  +     ##   specifically glmerControl -> tolPwrss
  + 
  +     library("lme4")
  +     library("testthat")
  +     ## data("trees513", package = "multcomp")
  +     load(system.file("testdata","trees513.RData",package="lme4"))
  + 
  + 
  +     expect_is(mmod1 <- glmer(damage ~ species - 1 + (1 | lattice / plot),
  +                              data = trees513B, family = binomial()),"glmerMod")
  +     if(FALSE) { ## Now (2019-05) defunct; was deprecated since 2013-06:
  +         expect_warning(mmod2 <- lmer(damage ~ species - 1 + (1 | lattice / plot),
  +                                      data = trees513B, family = binomial()),
  +                        "calling lmer with .* is deprecated")
  +         mmod2@call <- mmod1@call ## hack calls to equality
  +         expect_equal(mmod1,mmod2)
  +     }
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.15    0.04    0.18 
Running the tests in 'tests/lmer-0.R' failed.
Complete output:
  > require(lme4)
  Loading required package: lme4
  Loading required package: Matrix
  > source(system.file("test-tools-1.R", package = "Matrix"))# identical3() etc
  Loading required package: tools
  > 
  > ## use old (<=3.5.2) sample() algorithm if necessary
  > if ("sample.kind" %in% names(formals(RNGkind))) {
  +     suppressWarnings(RNGkind("Mersenne-Twister", "Inversion", "Rounding"))
  + }
  > 
  > ## Check that quasi families throw an error
  > assertError(lmer(cbind(incidence, size - incidence) ~ period + (1|herd),
  +                  data = cbpp, family = quasibinomial))
  > assertError(lmer(incidence ~ period + (1|herd),
  +                  data = cbpp, family = quasipoisson))
  > assertError(lmer(incidence ~ period + (1|herd),
  +                  data = cbpp, family = quasi))
  > 
  > ## check bug found by Kevin Buhr
  > set.seed(7)
  > n <- 10
  > X <- data.frame(y=runif(n), x=rnorm(n), z=sample(c("A","B"), n, TRUE))
  > fm <- lmer(log(y) ~ x | z, data=X)  ## ignore grouping factors with
  boundary (singular) fit: see help('isSingular')
  > ## gave error inside  model.frame()
  > stopifnot(all.equal(c(`(Intercept)` = -0.834544), fixef(fm), tolerance=.01))
  > 
  > ## is "Nelder_Mead" default optimizer?
  > (isNM   <- formals(lmerControl)$optimizer == "Nelder_Mead")
  [1] FALSE
  > (isOldB <- formals(lmerControl)$optimizer == "bobyqa")
  [1] FALSE
  > (isOldTol <- environment(nloptwrap)$defaultControl$xtol_abs == 1e-6)
  [1] FALSE
  > 
  > if (.Platform$OS.type != "windows") withAutoprint({
  + 
  +     source(system.file("testdata", "lme-tst-funs.R", package="lme4", mustWork=TRUE))# -> uc()
  + 
  +     ## check working of Matrix methods on  vcov(.) etc ----------------------
  +     fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  +      V  <- vcov(fm)
  +     (V1 <- vcov(fm1))
  +     (C1 <- chol(V1))
  +     dput(dV <- as.numeric(diag(V))) # 0.17607818634.. [x86_64, F Lnx 36]
  +     TOL <- 0 # to show the differences below
  +     TOL <- 1e-5 # for the check
  +     stopifnot(exprs = {
  +         all.equal(dV, uc(if(isNM)     0.176076 else if(isOldB) 0.176068575 else
  +                          if(isOldTol) 0.1761714 else           0.1760782),
  +                   tolerance = 9*TOL) # seen 7.8e-8; Apple clang 14.0.3 had 6.3783e-5
  +         all.equal(sqrt(dV), as.numeric(chol(V)), tol = 1e-12)
  +         all.equal(diag(V1), uc(`(Intercept)` = 46.5751, Days = 2.38947), tolerance = 40*TOL)# 5e-7 (for "all" algos)
  +         is(C1, "dtrMatrix") # was inherits(C1, "Cholesky")
  +         dim(C1) == c(2,2)
  +         all.equal(as.numeric(C1), # 6.8245967  0. -0.2126263  1.5310962 [x86_64, F Lnx 36]
  +                   c(6.82377, 0, -0.212575, 1.53127), tolerance=20*TOL)# 1.2e-4  ("all" algos)
  +         dim(chol(crossprod(getME(fm1, "Z")))) == 36
  +     })
  +     ## printing
  +     signif(chol(crossprod(getME(fm, "Z"))), 5) # -> simple 4 x 4 sparse
  + 
  +     showProc.time() #
  + 
  +     ## From: Stephane Laurent
  +     ## To:   r-sig-mixed-models@..
  +     ## "crash with the latest update of lme4"
  +     ##
  +     ## .. example for which lmer() crashes with the last update of lme4 ...{R-forge},
  +     ## .. but not with version CRAN version (0.999999-0)
  +     lsDat <- data.frame(
  +         Operator = as.factor(rep(1:5, c(3,4,8,8,8))),
  +         Part = as.factor(
  +             c(2L, 3L, 5L,
  +               1L, 1L, 2L, 3L,
  +               1L, 1L, 2L, 2L, 3L, 3L, 4L, 5L,
  +               1L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
  +               1L, 2L, 2L, 3L, 3L, 4L, 5L, 5L)),
  +         y =
  +             c(0.34, -1.23, -2.46,
  +               -0.84, -1.57,-0.31, -0.18,
  +               -0.94, -0.81, 0.77, 0.4, -2.37, -2.78, 1.29, -0.95,
  +               -1.58, -2.06, -3.11,-3.2, -0.1, -0.49,-2.02, -0.75,
  +               1.71,  -0.85, -1.19, 0.13, 1.35, 1.92, 1.04,  1.08))
  + 
  +     xtabs( ~ Operator + Part, data=lsDat) # --> 4 empty cells, quite a few with only one obs.:
  +     ##         Part
  +     ## Operator 1 2 3 4 5
  +     ##        1 0 1 1 0 1
  +     ##        2 2 1 1 0 0
  +     ##        3 2 2 2 1 1
  +     ##        4 1 1 2 2 2
  +     ##        5 1 2 2 1 2
  +     lsD29 <- lsDat[1:29, ]
  + 
  +     ## FIXME: rank-Z test should probably not happen in this case:
  +     (sm3 <- summary(m3 <- lm(y ~ Part*Operator, data=lsDat)))# ok: some interactions not estimable
  +     stopifnot(21 == nrow(coef(sm3)))# 21 *are* estimable
  +     sm4  <- summary(m4 <- lm(y ~ Part*Operator, data=lsD29))
  +     stopifnot(20 == nrow(coef(sm4)))# 20 *are* estimable
  +     lf <- lFormula(y ~ (1|Part) + (1|Operator) + (1|Part:Operator), data = lsDat)
  +     dim(Zt <- lf$reTrms$Zt)## 31 x 31
  +     c(rankMatrix(Zt)) ## 21
  +     c(rankMatrix(Zt,method="qr")) ## 31 ||  29 (64 bit Lnx), then 21 (!)
  +     c(rankMatrix(t(Zt),method="qr")) ## 30, then 21 !
  +     nrow(lsDat)
  +     fm3 <- lmer(y ~ (1|Part) + (1|Operator) + (1|Part:Operator), data = lsDat,
  +                 control=lmerControl(check.nobs.vs.rankZ="warningSmall"))
  + 
  +     lf29 <- lFormula(y ~ (1|Part) + (1|Operator) + (1|Part:Operator), data = lsD29)
  +     (fm4 <- update(fm3, data=lsD29))
  +     fm4. <- update(fm4, REML=FALSE,
  +                    control=lmerControl(optimizer="nloptwrap",
  +                                        optCtrl=list(ftol_abs=1e-6,
  +                                                     xtol_abs=1e-6)))
  +     ## summary(fm4.)
  +     stopifnot(
  +         all.equal(as.numeric(formatVC(VarCorr(fm4.), digits = 7)[,"Std.Dev."]),
  +                   c(1.040664, 0.6359187, 0.5291422, 0.4824796), tol = 1e-4)
  +     )
  +     showProc.time()
  + 
  + }) ## skip on windows (for speed)
  > 
  > 
  > cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
  Time elapsed:  1.34 0.28 1.56 NA NA 
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.34    0.28    1.56 
Running the tests in 'tests/lmer-conv.R' failed.
Complete output:
  > if (lme4:::testLevel() > 1 || .Platform$OS.type!="windows") {
  + ### lmer() convergence testing / monitoring / ...
  +     ##  ------------------
  + ### The output of tests here are *not* 'diff'ed  (<==> no *.Rout.save file)
  +     library(lme4)
  + 
  +     ## convergence on boundary warnings
  +     load(system.file("external/test3comp.rda", package = "Matrix"))
  +     b3 <- lmer(Y3 ~ (1|Sample) + (1|Operator/Run), test3comp, verb = TRUE)
  + 
  +     if (isTRUE(try(data(Early, package = 'mlmRev')) == 'Early')) {
  +         Early$tos <- Early$age - 0.5        # time on study
  +         b1 <- lmer(cog ~ tos + trt:tos + (tos|id), Early, verb = TRUE)
  +     }
  + 
  +     cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     1.68    0.29    1.96 
Running the tests in 'tests/methods.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") {
  +     library(lme4)
  +     library(testthat)
  +     fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  +     expect_equal(colnames(model.frame(fm1)),c("Reaction","Days","Subject"))
  +     expect_equal(colnames(model.frame(fm1,fixed.only=TRUE)),c("Reaction","Days"))
  +     expect_equal(formula(fm1),Reaction ~ Days + (Days | Subject))
  +     expect_equal(formula(fm1,fixed.only=TRUE),Reaction ~ Days)
  + 
  +     ## ugly example: model frame with compound elements
  +     fm2 <- lmer(log(Reaction) ~ splines::ns(Days,3) +
  +                     + I(1+Days^3) + (Days|Subject), sleepstudy)
  +     expect_equal(names(model.frame(fm2)),
  +                  c("log(Reaction)", "splines::ns(Days, 3)",
  +                    "I(1 + Days^3)", "Days", "Subject"))
  +     expect_equal(names(model.frame(fm2,fixed.only=TRUE)),
  +                  c("log(Reaction)", "splines::ns(Days, 3)",
  +                    "I(1 + Days^3)"))
  + 
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.06    0.20 
Running the tests in 'tests/minval.R' failed.
Complete output:
  > if (lme4:::testLevel() > 1 || .Platform$OS.type!="windows") {
  +     ## example posted by Stéphane Laurent
  +     ## exercises bug where Nelder-Mead min objective function value was >0
  +     set.seed(666)
  +     sims <- function(I, J, sigmab0, sigmaw0){
  +         Mu <- rnorm(I, mean=0, sd=sigmab0)
  +         y <- c(sapply(Mu, function(mu) rnorm(J, mu, sigmaw0)))
  +         data.frame(y=y, group=gl(I,J))
  +     }
  + 
  +     I <- 3  # number of groups
  +     J <- 8  # number of repeats per group
  +     sigmab0 <- 0.15  # between standard deviation
  +     sigmaw0 <- 0.15  # within standard deviation
  + 
  +     dat <- sims(I, J, sigmab0, sigmaw0)
  + 
  +     library(lme4)
  +     isOldTol <- environment(nloptwrap)$defaultControl$xtol_abs == 1e-6
  + 
  +     fm3 <- lmer(y ~ (1|group), data=dat)
  +     stopifnot(all.equal(unname(unlist(VarCorr(fm3))),
  +                         switch(fm3@optinfo$optimizer,
  +                                "Nelder_Mead" = 0.029662844,
  +                                "bobyqa"      = 0.029662698,
  +                                "nloptwrap"   =
  +                                    if (isOldTol) 0.029679755 else 0.029662699,
  +                                stop("need new case here: value is ",unname(unlist(VarCorr(fm3))))
  +                                ),
  +                         tolerance = 1e-7))
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     1.40    0.12    1.51 
Running the tests in 'tests/modFormula.R' failed.
Complete output:
  > if (.Platform$OS.type != "windows") {
  +     library(lme4)
  +     library(testthat)
  + 
  +     .get.checkingOpts <- lme4:::.get.checkingOpts
  +     stopifnot(identical(
  +         .get.checkingOpts(
  +             c("CheckMe", "check.foo", "check.conv.1", "check.rankZ", "check.rankX"))
  +       , c("check.foo", "check.rankZ")))
  + 
  +     lmod <- lFormula(Reaction ~ Days + (Days|Subject), sleepstudy)
  +     devfun <- do.call(mkLmerDevfun, lmod)
  +     opt <- optimizeLmer(devfun)
  +     cc <- lme4:::checkConv(attr(opt,"derivs"), opt$par, ctrl = lmerControl()$checkConv,
  +                            lbound=environment(devfun)$lower)
  +     fm1 <- mkMerMod(environment(devfun), opt, lmod$reTrms, fr = lmod$fr,
  +                     lme4conv=cc)
  +     fm2 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  + 
  +     ## basic equivalence
  +     fm1C <- fm1
  +     fm1C@call <- fm2@call
  +     expect_equal(fm2,fm1C)
  +     expect_equal(range(residuals(fm1)), c(-101.18, 132.547), tolerance = 1e-5) # these are "outliers"!
  +     expect_is(model.frame(fm1),"data.frame")
  +     ## formulae
  +     mfm1 <- model.frame(fm1)
  +     expect_equal(formula(fm1),         Reaction ~ Days + (Days | Subject))
  +     expect_equal(formula(terms(mfm1)), Reaction ~ Days + (Days + Subject))
  +     new_form_modframe <- (getRversion() >= "3.6.0" &&
  +                           as.numeric(version[["svn rev"]]) >= 75891)
  +     expect_equal(formula(mfm1),
  +                  if(new_form_modframe) {
  +                      Reaction ~ Days + (Days + Subject)
  +                  } else
  +                      Reaction ~ Days + Subject
  +                  )
  +     ## predictions
  +     expect_equal(predict(fm1,newdata=sleepstudy[1:10,],re.form=NULL),
  +                  predict(fm2,newdata=sleepstudy[1:10,],re.form=NULL))
  +     expect_equal(predict(fm1,newdata=sleepstudy),
  +                  predict(fm1))
  + 
  +     lmodOff <- lFormula(Reaction ~ Days + (Days|Subject) + offset(0.5*Days),
  +                         sleepstudy)
  +     devfunOff <- do.call(mkLmerDevfun, lmodOff)
  +     opt <- optimizeLmer(devfunOff)
  +     fm1Off <- mkMerMod(environment(devfunOff), opt, lmodOff$reTrms, fr = lmodOff$fr)
  +     fm2Off <- lmer(Reaction ~ Days + (Days|Subject) + offset(0.5*Days), sleepstudy)
  +     expect_equal(predict(fm1Off,newdata=sleepstudy[1:10,],re.form=NULL),
  +                  predict(fm2Off,newdata=sleepstudy[1:10,],re.form=NULL))
  + 
  +     ## FIXME: need more torture tests with offset specified, in different environments ...
  + 
  +     ## FIXME: drop1(.) doesn't work with modular objects ... hard to see how it
  +     ##  could, though ...
  +     ## drop1(fm1Off)
  +     drop1(fm2Off)
  + 
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     0.14    0.06    0.18 
Running the tests in 'tests/nlmer.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > 
  > allEQ <- function(x,y, tolerance = 4e-4, ...)
  +     all.equal.numeric(x,y, tolerance=tolerance, ...)
  > 
  > (nm1 <- nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ (Asym|Tree),
  +               Orange, start = c(Asym = 200, xmid = 725, scal = 350)))
  Nonlinear mixed model fit by maximum likelihood  ['nlmerMod']
  Formula: circumference ~ SSlogis(age, Asym, xmid, scal) ~ (Asym | Tree)
     Data: Orange
        AIC       BIC    logLik  deviance  df.resid 
   273.1438  280.9205 -131.5719  263.1438        30 
  Random effects:
   Groups   Name Std.Dev.
   Tree     Asym 31.646  
   Residual       7.843  
  Number of obs: 35, groups:  Tree, 5
  Fixed Effects:
   Asym   xmid   scal  
  192.1  727.9  348.1  
  > fixef(nm1)
      Asym     xmid     scal 
  192.0528 727.9045 348.0721 
  > 
  > if (lme4:::testLevel() > 2) {
  +     ## 'Theoph' Data modeling
  +     Th.start <- c(lKe = -2.5, lKa = 0.5, lCl = -3)
  + 
  + system.time(nm2 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
  +                          (lKe+lKa+lCl|Subject),
  +                          Theoph, start = Th.start,
  +                          control=nlmerControl(tolPwrss=1e-8)))
  + print(nm2, corr=FALSE)
  + 
  + system.time(nm3 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
  +                          (lKe|Subject) + (lKa|Subject) + (lCl|Subject),
  +                          Theoph, start = Th.start))
  + print(nm3, corr=FALSE)
  + 
  + ## dropping   lKe  from random effects:
  + system.time(nm4 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~ (lKa+lCl|Subject),
  +                          Theoph, start = Th.start,
  +                          control=nlmerControl(tolPwrss=1e-8)))
  + print(nm4, corr=FALSE)
  + 
  + system.time(nm5 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
  +                          (lKa|Subject) + (lCl|Subject),
  +                          Theoph,
  +                          start = Th.start,
  +                          control=nlmerControl(tolPwrss=1e-8)))
  +     print(nm5, corr=FALSE)
  + 
  +     ## this has not worked in a *long* time anyway, and PKPDmodels is currently archived, so ...
  +     
  +     ## if (require("PKPDmodels")) {
  +     ##     oral1cptSdlkalVlCl <-
  +     ##         PKmod("oral", "sd", list(ka ~ exp(lka), Cl ~ exp(lCl), V ~ exp(lV)))
  +     ##     if (FALSE) {
  +     ##         ## FIXME: Error in get(nm, envir = nlenv) : object 'k' not found
  +     ##         ##  probably with environments/call stack etc.?
  +     ##         ## 'pnames' is c("lV","lka","k") -- not ("lV","lka","lCl")
  +     ##         ##  nlmer -> nlformula -> MkRespMod
  +     ##         ##  pnames are OK in nlformula, but in MkRespMod we try to recover
  +     ##         ##   them from the column names of the gradient attribute of the
  +     ##         ##   model evaluated in nlenv -- which are wrong.
  +     ##         system.time(nm2a <- nlmer(conc ~ oral1cptSdlkalVlCl(Dose, Time, lV, lka, lCl) ~
  +     ##                                   (lV+lka+lCl|Subject),
  +     ##                                   Theoph, start = c(lV=-1, lka=-0.5, lCl=-3), tolPwrss=1e-8))
  +     ##         print(nm2a, corr=FALSE)
  +     ##     }
  +     ## }
  +     
  + }  ## testLevel > 2
  > 
  > proc.time()
     user  system elapsed 
     1.64    0.23    1.86 
Running the tests in 'tests/prLogistic.R' failed.
Complete output:
  > ## data set and formula extracted from ?prLogisticDelta example
  > ##   (Thailand, clustered-data) in prLogistic package
  > load(system.file("testdata","prLogistic.RData",package="lme4"))
  > library(lme4)
  Loading required package: Matrix
  > 
  > (testLevel <- lme4:::testLevel())
  [1] 1
  > if (testLevel > 2) {
  +     print(system.time(
  +     lme4_est <- glmer(rgi ~ sex + pped + (1|schoolid),
  +                       data = dataset, family=binomial)
  +     ))
  +     lme4_results <- list(sigma= sqrt(unname(unlist(VarCorr(lme4_est)))),
  +                          beta = fixef(lme4_est))
  + 
  +     ## stored results from other pkgs
  +     glmmML_est <- list(sigma = 1.25365353546143,
  +                        beta = c("(Intercept)" = -2.19478801858317,
  +                            "sex" = 0.548884468743364, "pped"= -0.623835613907385))
  +     lme4.0_est <- list(sigma = 1.25369539060849,
  +                        beta = c("(Intercept)" = -2.19474529099587,
  +                            "sex" = 0.548900267825802, "pped"= -0.623934772981894))
  + 
  +     source(system.file("test-tools-1.R", package = "Matrix"))#-> assert.EQ() etc
  +     assert.EQ.(lme4_results, glmmML_est, tol=3e-3)
  +     assert.EQ.(lme4_results, lme4.0_est, tol=3e-3)
  +     print(lme4_est)
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.50    0.26    1.76 
Running the tests in 'tests/predict_basis.R' failed.
Complete output:
  > ## test for models containing data-defined bases
  > 
  > ## ?makepredictcall
  > ## ?model.frame
  > ## ????
  > 
  > data(sleepstudy,package="lme4")
  > library(splines)
  > 
  > ## lm0 <- lm(Reaction~ns(Days,2),sleepstudy)
  > ## attr(terms(lm0),"predvars")
  > ## library(nlme)
  > ## lme1 <- lme(Reaction~ns(Days,2),random=~1|Subject,sleepstudy)
  > ## attr(terms(lme1),"predvars")  ## no!
  > ## attr(lme1$terms,"predvars")   ## yes
  > ## detach("package:nlme")
  > 
  > library(lme4)
  Loading required package: Matrix
  > fm1 <- lmer(Reaction ~ ns(Days,2) + (1|Subject), sleepstudy)
  > fm2 <- lmer(Reaction ~ poly(Days,2) + (1|Subject), sleepstudy)
  > fm3 <- lmer(Reaction ~ poly(Days,2,raw=TRUE) + (1|Subject), sleepstudy)
  > 
  > newdat0 <- data.frame(Days = unique(sleepstudy$Days))
  > newdat  <- data.frame(Days = 5:12)
  > tmpf <- function(fit) {
  +     with(sleepstudy, {
  +         plot  (Reaction~Days, xlim=c(0,12))
  +         points(Days, predict(fit), col=2)
  +     })
  +     lines(newdat0$ Days, predict(fit,ReForm=NA,newdata=newdat0), col=4)
  +     lines(newdat $ Days, predict(fit,ReForm=NA,newdata=newdat ), col=5)
  + }
  > 
  > stopifnot(all.equal(predict(fm2,newdat,ReForm=NA),
  +                     predict(fm3,newdat,ReForm=NA)))
  Warning messages:
  1: 'ReForm' is deprecated; use 're.form' instead 
  2: 'ReForm' is deprecated; use 're.form' instead 
  > 
  > ## pictures
  > tmpf(fm1)
  Warning messages:
  1: 'ReForm' is deprecated; use 're.form' instead 
  2: 'ReForm' is deprecated; use 're.form' instead 
  > tmpf(fm2)
  Warning messages:
  1: 'ReForm' is deprecated; use 're.form' instead 
  2: 'ReForm' is deprecated; use 're.form' instead 
  > tmpf(fm3)
  Warning messages:
  1: 'ReForm' is deprecated; use 're.form' instead 
  2: 'ReForm' is deprecated; use 're.form' instead 
  > 
  > ## test for GLMMs
  > set.seed(101)
  > d <- data.frame(y=rbinom(10,size=1,prob=0.5),
  +                 x=1:10,
  +                 f=factor(rep(1:5,each=2)))
  > gm1 <- glmer(y ~ poly(x,2) + (1|f), d, family=binomial)
  > gm2 <- glmer(y ~ poly(x,2,raw=TRUE) + (1|f), d, family=binomial)
  > 
  > newdat <- data.frame(x=c(1,4,6))
  > stopifnot(all.equal(predict(gm1,newdat,ReForm=NA),
  +                     predict(gm2,newdat,ReForm=NA),tolerance=3e-6))
  Warning messages:
  1: 'ReForm' is deprecated; use 're.form' instead 
  2: 'ReForm' is deprecated; use 're.form' instead 
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.93    0.20    2.12 
Running the tests in 'tests/predsim.R' failed.
Complete output:
  > ## compare range, average, etc. of simulations to
  > ## conditional and unconditional prediction
  > library(lme4)
  Loading required package: Matrix
  > do.plot <- FALSE
  > 
  > if (.Platform$OS.type != "windows") {
  + ## use old (<=3.5.2) sample() algorithm if necessary
  + if ("sample.kind" %in% names(formals(RNGkind))) {
  +     suppressWarnings(RNGkind("Mersenne-Twister", "Inversion", "Rounding"))
  + }
  + 
  + fm1 <- lmer(Reaction~Days+(1|Subject),sleepstudy)
  + set.seed(101)
  + pp <- predict(fm1)
  + rr <- range(usim2 <- simulate(fm1,1,use.u=TRUE)[[1]])
  + stopifnot(all.equal(rr,c(159.3896,439.1616),tolerance=1e-6))
  + if (do.plot) {
  +     plot(pp,ylim=rr)
  +     lines(sleepstudy$Reaction)
  +     points(simulate(fm1,1)[[1]],col=4)
  +     points(usim2,col=2)
  + }
  + 
  + set.seed(101)
  + 
  + ## conditional prediction
  + ss <- simulate(fm1,1000,use.u=TRUE)
  + ss_sum <- t(apply(ss,1,quantile,c(0.025,0.5,0.975)))
  + plot(pp)
  + matlines(ss_sum,col=c(1,2,1),lty=c(2,1,2))
  + stopifnot(all.equal(ss_sum[,2],pp,tolerance=5e-3))
  + 
  + ## population-level prediction
  + pp2 <- predict(fm1,ReForm=NA)
  + ss2 <- simulate(fm1,1000,use.u=FALSE)
  + ss_sum2 <- t(apply(ss2,1,quantile,c(0.025,0.5,0.975)))
  + 
  + if (do.plot) {
  +     plot(pp2,ylim=c(200,400))
  +     matlines(ss_sum2,col=c(1,2,1),lty=c(2,1,2))
  + }
  + 
  + stopifnot(all.equal(ss_sum2[,2],pp2,tolerance=8e-3))
  + 
  + ## predict(...,newdata=...) on models with derived variables in the random effects
  + ## e.g. (f:g, f/g)
  + set.seed(101)
  + d <- expand.grid(f=factor(letters[1:10]),g=factor(letters[1:10]),
  +                  rep=1:10)
  + d$y <- rnorm(nrow(d))
  + m1 <- lmer(y~(1|f:g),d)
  + p1A <- predict(m1)
  + p1B <- predict(m1,newdata=d)
  + stopifnot(all.equal(p1A,p1B))
  + m2 <- lmer(y~(1|f/g),d)
  + p2A <- predict(m2)
  + p2B <- predict(m2,newdata=d)
  + stopifnot(all.equal(p2A,p2B))
  + 
  + ## with numeric grouping variables
  + dn <- transform(d,f=as.numeric(f),g=as.numeric(g))
  + m1N <- update(m1,data=dn)
  + p1NA <- predict(m1N)
  + p1NB <- predict(m1N,newdata=dn)
  + stopifnot(all.equal(p1NA,p1NB))
  + 
  + ## simulate with modified parameters
  + set.seed(1)
  + s1 <- simulate(fm1)
  + set.seed(1)
  + s2 <- simulate(fm1,newdata=model.frame(fm1),
  +                newparams=getME(fm1,c("theta","beta","sigma")))
  + all.equal(s1,s2)
  + 
  + fm0 <- update(fm1,.~.-Days)
  + ##
  + ## sim() -> simulate() -> refit() -> deviance
  + ##
  + 
  + ## predictions and simulations with offsets
  + 
  + set.seed(101)
  + d <- data.frame(y=rpois(100,5),x=rlnorm(100,1,1),
  +                 f=factor(sample(10,size=100,replace=TRUE)))
  + gm1 <- glmer(y~offset(log(x))+(1|f),data=d,
  +              family=poisson)
  + s1 <- simulate(gm1)
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     1.20    0.21    1.42 
Running the tests in 'tests/priorWeightsModComp.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > n <- nrow(sleepstudy)
  > op <- options(warn = 1, # show as they happen ("false" convergence warnings)
  +               useFancyQuotes = FALSE)
  > 
  > if (.Platform$OS.type != "windows") {
  + ##' remove all attributes but names
  + dropA <- function(x) `attributes<-`(x, list(names = names(x)))
  + ##' transform result of "numeric" all.equal.list() to a named vector
  + all.eqL <- function(x1, x2, ...) {
  +     r <- sub("^Component ", '', all.equal(x1, x2, tolerance = 0, ...))
  +     r <- strsplit(sub(": Mean relative difference:", "&&", r),
  +                   split="&&", fixed=TRUE)
  +     setNames(as.numeric(vapply(r, `[`, "1.234", 2L)),
  +              ## drop surrounding "..."
  +              nm = sub('"$', '', substring(vapply(r, `[`, "nam",   1L), first=2)))
  + }
  + seedF <- function(s) {
  +     if(s %in% c(6, 39, 52, 57, 63, 74, 76, 86))
  +         switch(as.character(s)
  +                , "52"=, "63"=, "74" = 2
  +                , "6"=, "39" = 3
  +                , "86" =  8 # needs  4 on Lnx-64b
  +                , "76" = 70 # needs 42 on Lnx-64b
  +                , "57" = 90 # needs 52 on Lnx-64b
  +                )
  +     else if(s %in% c(1, 12, 15, 34, 36, 41, 42, 43, 49, 55, 59, 67, 80, 85)) ## seeds 41,59, .. 15
  +         1.0
  +     else ## seeds 22, 20, and better
  +         0.25
  + }
  + ## be fast, running only 10 seeds by default:
  + sMax <- if(lme4:::testLevel() > 1) 99L else 9L
  + mySeeds <- 0L:sMax
  + 
  + lapply(setNames(,mySeeds), function(seed) {
  +     cat("\n------ random seed =", seed, "---------\n")
  +     set.seed(seed)
  +     v <- rpois(n,1) + 1
  +     w <- 1/v
  +     cat("weights w:\n")
  +     fm1    <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy, REML=FALSE, weights = w); cat("..2:\n")
  +     fm2    <- lmer(Reaction ~ Days + (1    | Subject), sleepstudy, REML=FALSE, weights = w)
  +     cat("weights w*10:\n")
  +     fm1.10 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy, REML=FALSE, weights = w*10);cat("..2:\n")
  +     fm2.10 <- lmer(Reaction ~ Days + (1    | Subject), sleepstudy, REML=FALSE, weights = w*10)
  +     ##
  +     ano12... <- dropA(anova(fm1,    fm2   ))
  +     ano12.10 <- dropA(anova(fm1.10, fm2.10))
  +     print(aEQ <- all.eqL(ano12..., ano12.10)) # showing differences
  +     if(!exists("notChisq"))
  + 	notChisq <<-
  + 	    local({ n <- names(ano12...)
  + 		grep("Chisq", n, value=TRUE, fixed=TRUE, invert=TRUE) })
  +     stopifnot(
  +         all.equal(ano12...$Chisq,
  +                   ano12.10$Chisq, tol = 1e-6 * seedF(seed))
  +        ,
  +         all.equal(ano12...[notChisq],
  +                   ano12.10[notChisq], tol= 1.5e-8 * seedF(seed))
  +     )
  +     aEQ
  + }) -> rallEQ
  + 
  + cat("=====================================\n")
  + 
  + rallEQ <- t(simplify2array(rallEQ))
  + notChisq <- intersect(notChisq, colnames(rallEQ))
  + ## sort according to "severity":
  + srallEQ <- rallEQ[with(as.data.frame(rallEQ), order(AIC, Chisq)), ]
  + round(log10(srallEQ), 2)
  + saveRDS(srallEQ, "priorWeightsMod_relerr.rds")
  + 
  + if(!dev.interactive(orNone=TRUE)) pdf("priorWeightsMod_relerr.pdf")
  + 
  + matplot(mySeeds, log10(srallEQ), type="l", xlab=NA) ; grid()
  + legend("topleft", ncol=3, bty="n",
  +        paste(1:6, colnames(srallEQ), sep = ": "), col=1:6, lty=1:6)
  + tolD <- sqrt(.Machine$double.eps) # sqrt(eps_C)
  + abline(h = log10(tolD), col = "forest green", lty=3)
  + axis(4, at=log10(tolD), label=quote(sqrt(epsilon[c])), las=1)
  + LRG <- which(srallEQ[,"AIC"] > tolD)
  + if (length(LRG)>0) {
  +     text(LRG, log10(srallEQ[LRG, "AIC"]), names(LRG), cex = .8)
  + }
  + 
  + ## how close are we ..
  + str(tF <- sapply(mySeeds, seedF))
  + round(sort(      rallEQ[, "Chisq"] / (tF * 1e-6  ),          decreasing=TRUE), 1)
  + round(sort(apply(rallEQ[,notChisq] / (tF * 1.5e-8), 1, max), decreasing=TRUE), 1)
  + } ## skip on windows (for speed)
  > options(op)
  > 
  > proc.time()
     user  system elapsed 
     1.57    0.26    1.82 
Running the tests in 'tests/resids.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > 
  > ## raw residuals for LMMs
  > fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
  > stopifnot(all.equal(residuals(fm1),sleepstudy$Reaction-fitted(fm1)))
  > 
  > r1 <- residuals(fm1,type="pearson")
  > 
  > ## deviance/Pearson residuals for GLMMs
  > gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
  +              family = binomial, data = cbpp)
  > p <- fitted(gm1)
  > n <- cbpp$size
  > v <- n*p*(1-p)
  > obs_p <- cbpp$incidence/cbpp$size
  > rp <- residuals(gm1,"pearson")
  > rp1 <- (obs_p-p)/sqrt(p*(1-p))
  > rp2 <- rp1*n
  > ## FIXME:: restore this test
  > ## stopifnot(all.equal(rp,rp2))
  > 
  > r2 <- residuals(gm1,type="deviance")
  > 
  > proc.time()
     user  system elapsed 
     1.68    0.18    1.82 
Running the tests in 'tests/simulate.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > library(testthat)
  > 
  > (testLevel <- lme4:::testLevel())
  [1] 1
  > L <- load(system.file("testdata/lme-tst-fits.rda",
  +                       package="lme4", mustWork=TRUE))
  > 
  > if (testLevel>1) {
  + if (getRversion() > "3.0.0") {
  +     ## saved fits are not safe with old R versions
  + 
  + fm1 <- fit_sleepstudy_1
  + 
  +     
  + s1 <- simulate(fm1,seed=101)[[1]]
  + s2 <- simulate(fm1,seed=101,use.u=TRUE)
  + s3 <- simulate(fm1,seed=101,nsim=10)
  + s4 <- simulate(fm1,seed=101,use.u=TRUE,nsim=10)
  + stopifnot(length(s3)==10,all(sapply(s3,length)==180),
  +           length(s4)==10,all(sapply(s4,length)==180))
  + 
  + ## binomial (2-column and prob/weights)
  + gm1 <- fit_cbpp_1
  + gm2 <- fit_cbpp_3
  + 
  + gm1_s1 <- simulate(gm1,seed=101)[[1]]
  + gm1_s2 <- simulate(gm2,seed=101)[[1]]
  + stopifnot(all.equal(gm1_s1[,1]/rowSums(gm1_s1),gm1_s2))
  + gm1_s3 <- simulate(gm1,seed=101,use.u=TRUE)
  + gm1_s4 <- simulate(gm1,seed=101,nsim=10)
  + gm1_s5 <- simulate(gm2,seed=101,nsim=10)
  + stopifnot(length(gm1_s4)==10,all(sapply(gm1_s4,ncol)==2),all(sapply(gm1_s4,nrow)==56))
  + stopifnot(length(gm1_s5)==10,all(sapply(gm1_s5,length)==56))
  + 
  + ## binomial (factor): Kubovy bug report 1 Aug 2013
  + d <- data.frame(y=factor(rep(letters[1:2],each=100)),
  +                 f=factor(rep(1:10,10)))
  + g1 <- glmer(y~(1|f),data=d,family=binomial)
  + s6 <- simulate(g1,nsim=10)
  + stopifnot(length(s6)==10,all(sapply(s6,length)==200))
  + 
  + ## test explicitly stated link function
  + gm3 <- glmer(cbind(incidence, size - incidence) ~ period +
  +              (1 | herd), data = cbpp, family = binomial(link="logit"))
  + s4 <- simulate(gm3,seed=101)[[1]]
  + stopifnot(all.equal(gm1_s1,s4))
  + 
  + cbpp$obs <- factor(seq(nrow(cbpp)))
  + gm4 <- fit_cbpp_2
  + ## glmer(cbind(incidence, size - incidence) ~ period +
  + ##             (1 | herd) + (1|obs), data = cbpp, family = binomial)
  + 
  + s5 <- simulate(gm4,seed=101)[[1]]
  + s6 <- simulate(gm4,seed=101,use.u=TRUE)[[1]]
  + 
  + ## Bernoulli
  + ## works, but too slow
  + if (testLevel > 2) {
  +     if(require("mlmRev")) {
  +         data(guImmun, package="mlmRev")
  +         table(guImmun$immun)
  +         ##    N    Y
  +         ## 1195  964
  +         g1i <- glmer(immun ~ kid2p+mom25p+ord+ethn+momEd+husEd+momWork+rural+pcInd81+
  +                          (1|comm/mom), family="binomial", data=guImmun)
  +         ## In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  +         ##    Model failed to converge with max|grad| = 0.326795 (tol = 0.002, component 1)
  +         sg1 <- simulate(g1i)
  +         if(FALSE) { ## similar: not relevant here {comment out for 'R CMD check'}:
  +         ## if(require("glmmTMB")) {
  +             g2 <- glmmTMB(immun ~ kid2p+mom25p+ord+ethn+momEd+husEd+momWork+rural+pcInd81+
  +                           (1|comm/mom), family="binomial", data=guImmun)
  +             sg2 <- simulate(g2)
  +         ## }
  +         }
  +     }
  + }
  + 
  + set.seed(101)
  + d <- data.frame(f = factor(rep(LETTERS[1:10],each=10)))
  + d$x <- runif(nrow(d))
  + u <- rnorm(10)
  + d$eta <- with(d, 1 + 2*x + u[f])
  + d$y <- rbinom(nrow(d), size=1, prob = plogis(d$eta))
  + 
  + g1 <- glmer(y ~ x + (1|f), data=d, family="binomial")
  + ## tolPwrss=1e-5: no longer necessary
  + 
  + if (testLevel > 2) { ## trying a set of  glmerControl(tolPwrss = 10^t) :
  +   allcoef <- function(x) c(dev = deviance(x), th = getME(x,"theta"), beta = getME(x,"beta"))
  +   tfun <- function(t) {
  +       gg <- try( ## << errors (too small tolPwrss) are still printed :
  +           glmer(y~x+(1|f),data=d,family="binomial",
  +                     control = glmerControl(tolPwrss = 10^t)))
  +     if (inherits(gg,"try-error")) rep(NA,4) else allcoef(gg)
  +   }
  +   tvec <- seq(-4,-16,by=-0.25)
  +   tres <- cbind(t = tvec, t(sapply(tvec, tfun)))
  +   print(tres)
  + }
  + 
  + gm_s5 <- simulate(g1, seed=102)[[1]]
  + 
  + d$y <- factor(c("N","Y")[d$y+1])
  + g1B <- glmer(y ~ x + (1|f), data=d, family="binomial") ## ,tolPwrss=1e-5)
  + s1B <- simulate(g1B, seed=102)[[1]]
  + stopifnot(all.equal(gm_s5,as.numeric(s1B)-1))
  + 
  + ## another Bernoulli
  + if(requireNamespace("mlmRev")) {
  +     data(Contraception, package="mlmRev")
  +     gm5 <- glmer(use ~ urban+age+livch+(1|district), Contraception, binomial)
  +     s3 <- simulate(gm5)
  + }
  + d$y <- rpois(nrow(d),exp(d$eta))
  + gm6 <- glmer(y~x+(1|f),data=d,family="poisson")
  + s4 <- simulate(gm6)
  + 
  + ## simulation 'from scratch' with formulas:
  + ## binomial
  + ## form <- formula(gm1)[-2]
  + form <- ~ (1|herd) + period
  + gm1_s4 <- simulate(form,newdata=model.frame(gm1),
  +                newparams=list(theta=getME(gm1,"theta"),
  +                beta=fixef(gm1)),
  +                family=binomial,
  +                weights=rowSums(model.frame(gm1)[[1]]),
  +                seed=101)[[1]]
  + stopifnot(all.equal(gm1_s2,gm1_s4))
  + 
  + gm1_s5 <- simulate(formula(gm1),newdata=cbpp,
  +                newparams=list(theta=getME(gm1,"theta"),
  +                beta=fixef(gm1)),
  +                family=binomial,
  +                seed=101)[[1]]
  + stopifnot(all.equal(gm1_s1,gm1_s5))
  + 
  + tt <- getME(gm1,"theta")
  + bb <- fixef(gm1)
  + expect_message(simulate(form,newdata=model.frame(gm1),
  +                newparams=list(theta=unname(tt),
  +                beta=fixef(gm1)),
  +                family=binomial,
  +                weights=rowSums(model.frame(gm1)[[1]]),
  +                seed=101),"assuming same order")
  + expect_error(simulate(form,newdata=model.frame(gm1),
  +                newparams=list(theta=setNames(tt,"abc"),
  +                beta=fixef(gm1)),
  +                family=binomial,
  +                weights=rowSums(model.frame(gm1)[[1]]),
  +                seed=101),"mismatch between")
  + expect_message(simulate(form,newdata=model.frame(gm1),
  +                newparams=list(theta=tt,
  +                beta=unname(bb)),
  +                family=binomial,
  +                weights=rowSums(model.frame(gm1)[[1]]),
  +                seed=101),"assuming same order")
  + expect_error(simulate(form,newdata=model.frame(gm1),
  +                newparams=list(theta=tt,
  +                beta=setNames(bb,c("abc",names(bb)[-1]))),
  +                family=binomial,
  +                weights=rowSums(model.frame(gm1)[[1]]),
  +                seed=101),"mismatch between")
  + 
  + ## Gaussian
  + form <- formula(fm1)[-2]
  + s7 <- simulate(form,newdata=model.frame(fm1),
  +                newparams=list(theta=getME(fm1,"theta"),
  +                beta=fixef(fm1),
  +                sigma=sigma(fm1)),
  +                family=gaussian,
  +                seed=101)[[1]]
  + stopifnot(all.equal(s7,s1))
  + 
  + ## TO DO: wider range of tests, including offsets ...
  + 
  + }# R >= 3.0.0
  + } ## testLevel>1
  > 
  > proc.time()
     user  system elapsed 
     1.92    0.21    2.09 
Running the tests in 'tests/test-glmernbref.R' failed.
Complete output:
  > ## DON'T load lme4; test is to see if glmer.nb works when
  > ## lme4 is not loaded
  > 
  > set.seed(101)
  > dd <- data.frame(x=runif(200), f= rep(1:20, each=10))
  > b <- rnorm(20)
  > dd <- transform(dd, y = rnbinom(200, mu  = exp(1 + 2*x + b[f]), size = 2))
  > g <- lme4::glmer.nb(y~x + (1|f), data = dd)
  > stopifnot(inherits(g, "glmerMod"))
  > 
  > proc.time()
     user  system elapsed 
     2.98    0.31    3.28 
Running the tests in 'tests/testOptControl.R' failed.
Complete output:
  > ## https://github.com/lme4/lme4/issues/59
  > library(lme4)
  Loading required package: Matrix
  > dat <- read.csv(system.file("testdata","dat20101314.csv",package="lme4"))
  > NMcopy <- lme4:::Nelder_Mead
  > 
  > cc <- capture.output(lmer(y ~ (1|Operator)+(1|Part)+(1|Part:Operator), data=dat,
  +                           control=
  +                           lmerControl("NMcopy", 
  +                                       optCtrl= list(iprint=20))))
  > 
  > ## check that printing goes through step 140 twice and up to 240 once
  > ## findStep <- function(str,n) sum(grepl(paste0("\\(NM\\) ",n,": "),str))
  > cc <- paste(cc,collapse="")
  > countStep <- function(str,n) {
  +     length(gregexpr(paste0("\\(NM\\) ",n,": "),str)[[1]])
  + }
  > 
  > stopifnot(countStep(cc,140)==2 && countStep(cc,240)==1)
  > 
  > ## testStr <-
  > ## "(NM) 20: f = -53.3709 at 0.706667 0.813333  1.46444(NM) 40: f = -147.132 at     0     0 19.18(NM) 60: f = -147.159 at       0       0 17.4275(NM) 80: f = -147.159 at       0       0 17.5615(NM) 100: f = -147.159 at    0       0 17.5754(NM) 120: f = -147.159 at       0       0 17.5769(NM) 140: f = -147.159 at       0       0 17.5768(NM) 20: f = -165.55 at 0.0933333  0.573333   17.3168(NM) 40: f = -173.704 at 0.23799  1.4697 16.9728(NM) 60: f = -173.849 at 0.449634  1.39998  16.9452(NM) 80: f = -174.421 at 0.52329 1.69123 18.1534(NM) 100: f = -176.747 at 0.762043  1.88271  32.8993(NM) 120: f = -176.839 at 0.751206  1.75371 37.2128(NM) 140: f = -176.853 at 0.706425   1.7307  35.7528(NM) 160: f = -176.853 at 0.710803  1.73476  35.7032(NM) 180: f = -176.853 at 0.710159  1.73449  35.6699(NM) 200: f = -176.853 at 0.710271  1.73461 35.6689(NM) 220: f = -176.853 at 0.710259   1.7346  35.6684(NM) 240: f = -176.853 at 0.710257  1.73459  35.6685Linear mixed model fit by REML ['lmerMod']"
  > 
  > proc.time()
     user  system elapsed 
     1.73    0.17    1.89 
Running the tests in 'tests/varcorr.R' failed.
Complete output:
  > library(lme4)
  Loading required package: Matrix
  > 
  > if (.Platform$OS.type != "windows") {
  + data(Orthodont, package="nlme")
  + fm1 <- lmer(distance ~ age + (age|Subject), data = Orthodont)
  + VarCorr(fm1)
  + 
  + fm2ML <- lmer(diameter ~ 1 + (1|plate) + (1|sample), Penicillin, REML=0)
  + VarCorr(fm2ML)
  + 
  + gm1 <- glmer(cbind(incidence,size-incidence) ~ period + (1|herd),data=cbpp,
  +              family=binomial)
  + VarCorr(gm1)
  + 
  + cbpp$obs <- factor(seq(nrow(cbpp)))
  + gm2 <- update(gm1,.~.+(1|obs))
  + VarCorr(gm2)
  + 
  + if (FALSE) {
  +   ## testing lme4/lme4 incompatibility
  + ##  library(lme4)
  +   VarCorr(fm1)
  +   lme4:::VarCorr.merMod(fm1) ## OK
  + }
  + } ## skip on windows (for speed)
  > 
  > proc.time()
     user  system elapsed 
     1.57    0.14    1.70