[Lme4-commits] r1586 - pkg/lme4Eigen/inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 9 19:41:25 CET 2012


Author: dmbates
Date: 2012-02-09 19:41:24 +0100 (Thu, 09 Feb 2012)
New Revision: 1586

Added:
   pkg/lme4Eigen/inst/tests/test-lmer.R
Log:
Add new test file using testthat.


Added: pkg/lme4Eigen/inst/tests/test-lmer.R
===================================================================
--- pkg/lme4Eigen/inst/tests/test-lmer.R	                        (rev 0)
+++ pkg/lme4Eigen/inst/tests/test-lmer.R	2012-02-09 18:41:24 UTC (rev 1586)
@@ -0,0 +1,28 @@
+library("testthat")
+context("fitting mixed-effects models")
+
+test_that("lmer", {
+    expect_that(fm1 <- lmer(Yield ~ 1|Batch, Dyestuff), is_a("lmerMod"))
+    expect_that(fm1 at resp,                               is_a("lmerResp"))
+    expect_that(fm1 at pp,                                 is_a("merPredD"))
+    expect_that(fe1 <- fixef(fm1),                      is_equivalent_to(1527.5))
+    expect_that(VarCorr(fm1)[[1]][1,1],                 equals(1764.07265427677))
+    expect_that(isREML(fm1),                            equals(TRUE))
+    expect_that(REMLfun <- as.function(fm1),            is_a("function"))
+    expect_that(REMLfun(1),                             equals(319.792389042002))
+    expect_that(REMLfun(0),                             equals(326.023232155879))
+    expect_that(family(fm1),                            equals(gaussian()))
+    expect_that(isREML(fm1ML <- refitML(fm1)),          equals(FALSE))
+    expect_that(is.na(deviance(fm1)),                   equals(TRUE))
+    expect_that(deviance(fm1ML),                        equals(327.327059881135))
+    expect_that(sigma(fm1),                             equals(49.5100503990048))
+    expect_that(sigma(fm1ML),                           equals(49.5100999308089))
+    expect_that(extractAIC(fm1),                        equals(c(3, 333.327059881135)))
+    expect_that(extractAIC(fm1ML),                      equals(c(3, 333.327059881135)))
+    expect_that(vcov(fm1)[1,1],                         equals(375.720278729861))
+    expect_that(vcov(fm1ML)[1,1],                       equals(313.097224695739))
+    expect_that(fm2 <- refit(fm1, Dyestuff2$Yield),     is_a("lmerMod"))
+    expect_that(fixef(fm2),                             is_equivalent_to(5.6656))
+    expect_that(VarCorr(fm2)[[1]][1,1],                 equals(0))
+})
+



More information about the Lme4-commits mailing list