[Lme4-commits] r1806 - pkg/lme4.0/tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 10 01:11:01 CEST 2013
Author: bbolker
Date: 2013-04-10 01:11:01 +0200 (Wed, 10 Apr 2013)
New Revision: 1806
Modified:
pkg/lme4.0/tests/lmer-1.R
pkg/lme4.0/tests/lmer-1.Rout.save
pkg/lme4.0/tests/nlmer.R
pkg/lme4.0/tests/nlmer.Rout.save
Log:
cosmetic updates to tests (reduce output precision to allow more robust comparisons of saved output)
Modified: pkg/lme4.0/tests/lmer-1.R
===================================================================
--- pkg/lme4.0/tests/lmer-1.R 2013-04-09 21:31:02 UTC (rev 1805)
+++ pkg/lme4.0/tests/lmer-1.R 2013-04-09 23:11:01 UTC (rev 1806)
@@ -1,4 +1,5 @@
### suppressPackageStartupMessages(...) as we have an *.Rout.save to Rdiff against
+## ?? FIXME: options(digits=4) ???
stopifnot(suppressPackageStartupMessages(require(lme4.0)))
options(show.signif.stars = FALSE)
@@ -39,7 +40,9 @@
y <- rnorm (n, a.group[group.id], 1)
## fit and summarize the model
fit.1 <- lmer (y ~ 1 + (1 | group.id))
-coef (fit.1)# failed in Matrix 0.99-6
+op <- options(digits=4) ## reduce precision for more robust comparisons
+coef (fit.1) # failed in Matrix 0.99-6
+options(op)
(sf1 <- summary(fit.1)) # show() is as without summary()
@@ -113,18 +116,32 @@
M1 <- lmer (y ~ 1 | group)
mcmcsamp (M1, n = 2, saveb=TRUE) # fine
- M2. <- lmer (y ~ 1 + x + (1 + x | group)) # had false convergence
+ M2. <- lmer (y ~ 1 + x + (1 + x | group)) # had false convergence
## convergence now ok (but ranef corr. = -1; fixef = -.996 :
- summary(M2.)
+ op <- options(digits=4)
+ fixef(M2.)
+ cov2cor(vcov(M2.))
+ ## discrepancies have occured at digit 140.641x;
+ ## digits= doesn't handle it properly since other
+ ## elements have smaller magnitudes
+ round(c(unlist(VarCorr(M2.))),3)
+ options(op)
+ ## summary(M2.)
M2 <- lmer (y ~ x + ( x | group))
## should be identical (and is .. well, not on all versions on Mac OSX):
stopifnot(identical(fixef(M2), fixef(M2.)),
identical(ranef(M2), ranef(M2.)),
identical(resid(M2), resid(M2.)))
+ op <- options(digits=3)
mcmcsamp (M2, saveb=TRUE)
+ options(op)
+ ## note: M2 at dims["cvg"] (convergence indicator from PORT optimization)
+ ## changed between versions from 4="relative function convergence" to
+ ## 5="both X- and relative function convergence"
if (FALSE) { # mcmcsamp for glmer not yet available
+ ## ... and may never be ...
## mcmc for glmer:
rG1k <- mcmcsamp(m1, n = 1000)
Modified: pkg/lme4.0/tests/lmer-1.Rout.save
===================================================================
--- pkg/lme4.0/tests/lmer-1.Rout.save 2013-04-09 21:31:02 UTC (rev 1805)
+++ pkg/lme4.0/tests/lmer-1.Rout.save 2013-04-09 23:11:01 UTC (rev 1806)
@@ -1,13 +1,15 @@
-R version 2.15.1 beta (2012-06-14 r59562) -- "Roasted Marshmallows"
+R Under development (unstable) (2012-12-14 r61321) -- "Unsuffered Consequences"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
-Platform: x86_64-unknown-linux-gnu (64-bit)
+Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
+ Natural language support but running in an English locale
+
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
@@ -17,6 +19,7 @@
Type 'q()' to quit R.
> ### suppressPackageStartupMessages(...) as we have an *.Rout.save to Rdiff against
+> ## ?? FIXME: options(digits=4) ???
> stopifnot(suppressPackageStartupMessages(require(lme4.0)))
> options(show.signif.stars = FALSE)
>
@@ -143,20 +146,22 @@
> y <- rnorm (n, a.group[group.id], 1)
> ## fit and summarize the model
> fit.1 <- lmer (y ~ 1 + (1 | group.id))
-> coef (fit.1)# failed in Matrix 0.99-6
+> op <- options(digits=4) ## reduce precision for more robust comparisons
+> coef (fit.1) # failed in Matrix 0.99-6
$group.id
(Intercept)
-1 3.3760688
-2 -0.2385223
-3 3.1860179
-4 3.1121968
-5 1.4381076
-6 -1.7594786
-7 -0.2546842
-8 0.6977648
-9 1.2121675
-10 4.9434830
+1 3.3761
+2 -0.2385
+3 3.1860
+4 3.1122
+5 1.4381
+6 -1.7595
+7 -0.2547
+8 0.6978
+9 1.2122
+10 4.9435
+> options(op)
> (sf1 <- summary(fit.1)) # show() is as without summary()
Linear mixed model fit by REML
Formula: y ~ 1 + (1 | group.id)
@@ -254,7 +259,7 @@
+ reg <- lmer(y ~ habitat + (1|habitat*lagoon), data = dat) # did seg.fault
+ ) # now gives error ^- should be ":"
Error in mer_finalize(ans) :
- Cholmod error 'invalid xtype' at file:../Cholesky/cholmod_solve.c, line 971
+ Cholmod error 'invalid xtype' at file:../Cholesky/cholmod_solve.c, line 970
In addition: Warning message:
In Ops.factor(habitat, lagoon) : * not meaningful for factors
>
@@ -281,9 +286,9 @@
> has.coda <- require(coda)
Loading required package: coda
-Attaching package: 'coda'
+Attaching package: ‘coda’
-The following object(s) are masked from 'package:lme4.0':
+The following object is masked from ‘package:lme4.0’:
HPDinterval
@@ -437,78 +442,81 @@
[1,] 9.511644 9.43961
>
-> M2. <- lmer (y ~ 1 + x + (1 + x | group)) # had false convergence
+> M2. <- lmer (y ~ 1 + x + (1 + x | group)) # had false convergence
> ## convergence now ok (but ranef corr. = -1; fixef = -.996 :
-> summary(M2.)
-Linear mixed model fit by REML
-Formula: y ~ 1 + x + (1 + x | group)
- AIC BIC logLik deviance REMLdev
- 101.5 107.5 -44.77 87.59 89.54
-Random effects:
- Groups Name Variance Std.Dev. Corr
- group (Intercept) 140.641531 11.85924
- x 0.014427 0.12011 -1.000
- Residual 2.722977 1.65014
-Number of obs: 20, groups: group, 2
-
-Fixed effects:
- Estimate Std. Error t value
-(Intercept) 15.23552 8.40776 1.812
-x 0.18559 0.08508 2.181
-
-Correlation of Fixed Effects:
- (Intr)
-x -0.996
+> op <- options(digits=4)
+> fixef(M2.)
+(Intercept) x
+ 15.2355 0.1856
+> cov2cor(vcov(M2.))
+2 x 2 Matrix of class "dpoMatrix"
+ [,1] [,2]
+[1,] 1.0000 -0.9961
+[2,] -0.9961 1.0000
+> ## discrepancies have occured at digit 140.641x;
+> ## digits= doesn't handle it properly since other
+> ## elements have smaller magnitudes
+> round(c(unlist(VarCorr(M2.))),3)
+ group1 group2 group3 group4
+140.641 -1.424 -1.424 0.014
+> options(op)
+> ## summary(M2.)
> M2 <- lmer (y ~ x + ( x | group))
> ## should be identical (and is .. well, not on all versions on Mac OSX):
> stopifnot(identical(fixef(M2), fixef(M2.)),
+ identical(ranef(M2), ranef(M2.)),
+ identical(resid(M2), resid(M2.)))
>
+> op <- options(digits=3)
> mcmcsamp (M2, saveb=TRUE)
An object of class "merMCMC"
Slot "Gp":
[1] 0 4
Slot "ST":
- [,1]
-[1,] 7.18678711
-[2,] 0.00000000
-[3,] -0.01012811
+ [,1]
+[1,] 7.1868
+[2,] 0.0000
+[3,] -0.0101
Slot "call":
lmer(formula = y ~ x + (x | group))
Slot "deviance":
-[1] 87.58733
+[1] 87.6
Slot "dims":
nt n p q s np LMM REML fTyp lTyp vTyp nest useSc
1 20 2 4 1 3 1 1 2 5 1 1 1
nAGQ verb mxit mxfn cvg
- 1 0 300 900 5
+ 1 0 300 900 4
Slot "fixef":
- [,1]
-(Intercept) 15.2355231
-x 0.1855856
+ [,1]
+(Intercept) 15.236
+x 0.186
Slot "nc":
[1] 2
Slot "ranef":
- [,1]
-[1,] -8.35048135
-[2,] 8.35048135
-[3,] 0.08457456
-[4,] -0.08457456
+ [,1]
+[1,] -8.3505
+[2,] 8.3505
+[3,] 0.0846
+[4,] -0.0846
Slot "sigma":
- [,1]
-[1,] 1.650145
+ [,1]
+[1,] 1.65
+> options(op)
+> ## note: M2 at dims["cvg"] (convergence indicator from PORT optimization)
+> ## changed between versions from 4="relative function convergence" to
+> ## 5="both X- and relative function convergence"
>
> if (FALSE) { # mcmcsamp for glmer not yet available
++ ## ... and may never be ...
+
+ ## mcmc for glmer:
+ rG1k <- mcmcsamp(m1, n = 1000)
@@ -635,8 +643,8 @@
> if(.unsafe.BLAS) rm(identical)
>
> cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
-Time elapsed: 6.352 0.052 6.414 0 0
+Time elapsed: 7.204 2.836 10.664 0.012 0.096
>
> proc.time()
user system elapsed
- 6.352 0.052 6.414
+ 7.216 2.936 10.666
Modified: pkg/lme4.0/tests/nlmer.R
===================================================================
--- pkg/lme4.0/tests/nlmer.R 2013-04-09 21:31:02 UTC (rev 1805)
+++ pkg/lme4.0/tests/nlmer.R 2013-04-09 23:11:01 UTC (rev 1806)
@@ -14,9 +14,11 @@
## 'Theoph' Data modeling
Th.start <- c(lKe = -2.5, lKa = 0.5, lCl = -3)
+op <- options(digits=3)
(nm2 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
(lKe+lKa+lCl|Subject),
Theoph, start = Th.start))
+options(op)
showProc.time() # ~ 5.7s {dual-opteron 2814, on 64b, no optim.}
(nm3 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
Modified: pkg/lme4.0/tests/nlmer.Rout.save
===================================================================
--- pkg/lme4.0/tests/nlmer.Rout.save 2013-04-09 21:31:02 UTC (rev 1805)
+++ pkg/lme4.0/tests/nlmer.Rout.save 2013-04-09 23:11:01 UTC (rev 1806)
@@ -1,13 +1,15 @@
-R version 2.14.2 RC (2012-02-26 r58499)
+R Under development (unstable) (2012-12-14 r61321) -- "Unsuffered Consequences"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
-Platform: x86_64-unknown-linux-gnu (64-bit)
+Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
+ Natural language support but running in an English locale
+
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
@@ -32,34 +34,36 @@
> ## 'Theoph' Data modeling
>
> Th.start <- c(lKe = -2.5, lKa = 0.5, lCl = -3)
+> op <- options(digits=3)
> (nm2 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
+ (lKe+lKa+lCl|Subject),
+ Theoph, start = Th.start))
Nonlinear mixed model fit by the Laplace approximation
Formula: conc ~ SSfol(Dose, Time, lKe, lKa, lCl) ~ (lKe + lKa + lCl | Subject)
Data: Theoph
- AIC BIC logLik deviance
- 152.1 181 -66.07 132.1
+ AIC BIC logLik deviance
+ 152 181 -66.1 132
Random effects:
Groups Name Variance Std.Dev. Corr
- Subject lKe 0.000000 0.00000
- lKa 0.227357 0.47682 NaN
- lCl 0.015722 0.12539 NaN -0.012
- Residual 0.591716 0.76923
+ Subject lKe 0.0000 0.000
+ lKa 0.2274 0.477 NaN
+ lCl 0.0157 0.125 NaN -0.012
+ Residual 0.5917 0.769
Number of obs: 132, groups: Subject, 12
Fixed effects:
Estimate Std. Error t value
-lKe -2.47518 0.05641 -43.88
-lKa 0.47414 0.15288 3.10
-lCl -3.23551 0.05235 -61.80
+lKe -2.4752 0.0564 -43.9
+lKa 0.4741 0.1529 3.1
+lCl -3.2355 0.0524 -61.8
Correlation of Fixed Effects:
lKe lKa
lKa -0.264
lCl 0.671 -0.141
+> options(op)
> showProc.time() # ~ 5.7s {dual-opteron 2814, on 64b, no optim.}
-Time elapsed: 7.571 0.06 7.807
+Time elapsed: 5.432 0.012 5.456
>
> (nm3 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
+ (lKe|Subject) + (lKa|Subject) + (lCl|Subject),
@@ -72,23 +76,23 @@
Random effects:
Groups Name Variance Std.Dev.
Subject lKe 0.000000 0.00000
- Subject lKa 0.227493 0.47696
+ Subject lKa 0.227490 0.47696
Subject lCl 0.015738 0.12545
- Residual 0.591689 0.76921
+ Residual 0.591692 0.76921
Number of obs: 132, groups: Subject, 12
Fixed effects:
Estimate Std. Error t value
lKe -2.47500 0.05641 -43.88
lKa 0.47408 0.15291 3.10
-lCl -3.23539 0.05236 -61.79
+lCl -3.23538 0.05236 -61.79
Correlation of Fixed Effects:
lKe lKa
lKa -0.264
lCl 0.671 -0.133
> showProc.time() # ~ 3.2s
-Time elapsed: 5.408 0.044 5.572
+Time elapsed: 4.536 0.128 4.692
>
> ## dropping lKe from random effects:
> (nm4 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
@@ -117,7 +121,7 @@
lKa -0.264
lCl 0.671 -0.141
> showProc.time()
-Time elapsed: 2.925 0.013 2.985
+Time elapsed: 3.233 0.068 3.381
>
> (nm5 <- nlmer(conc ~ SSfol(Dose, Time,lKe, lKa, lCl) ~
+ (lKa|Subject) + (lCl|Subject),
@@ -145,7 +149,7 @@
lKa -0.264
lCl 0.671 -0.133
> showProc.time()
-Time elapsed: 2.514 0 2.55
+Time elapsed: 2.8 0.068 2.95
>
> e3 <- expand(nm3)
> stopifnot(identical(sapply(e3, class),
@@ -171,5 +175,8 @@
+ )
>
> showProc.time()
-Time elapsed: 0.037 0 0.037
+Time elapsed: 0.04 0.04 0.08
>
+> proc.time()
+ user system elapsed
+ 19.713 2.692 23.289
More information about the Lme4-commits
mailing list