[R-sig-ME] Timing for lmer2 versus lmer for chocolate cake data (WinXP)
Andrew Robinson
A.Robinson at ms.unimelb.edu.au
Sun Jan 28 20:01:25 CET 2007
I've switched from FreeBSD to WinXP temporarily :)
I've attached a comparison of lmer and lmer2 upon the analysis of
Cochran and Cox's chocolate cake data. Here, it seems that lmer2 is
faster (0.08 vs. 0.15) but the AIC of the fitted model for lmer2 is
higher (1643 vs 1635). The models are quite different in the random
effects.
The data, script, and output are attached.
Cheers,
Andrew
--
Andrew Robinson
Department of Mathematics and Statistics Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cake.csv
Type: text/csv
Size: 11115 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20070129/f3fd9ff6/attachment.bin>
-------------- next part --------------
# The chocolate cake breakage data are referred to in section 5.5 of
# \citet{lee+nelder+pawitan-2006} as an example of a normal-normal
# hiearchical generalized linear model. The data are originally from
# \citet{cochran+cox-1957}.
require(lme4)
cake <- read.csv("cake.csv")
names(cake) <- c("replicate","batch","recipe","temperature","angle")
cake$recipe <- factor(cake$recipe)
cake$replicate <- factor(cake$replicate)
cake$batch <- factor(cake$batch)
cake$temperature <- factor(cake$temperature)
dim(cake)
head(cake)
system.time(cake.lmer <- lmer(angle ~ recipe * temperature +
(1 | replicate/batch),
data = cake))
summary(cake.lmer)
system.time(cake.lmer2 <- lmer2(angle ~ recipe * temperature +
(1 | replicate/batch),
data = cake))
summary(cake.lmer2)
sessionInfo()
-------------- next part --------------
> require(lme4)
[1] TRUE
> cake <- read.csv("cake.csv")
> names(cake) <- c("replicate", "batch", "recipe", "temperature",
"angle")
> cake$recipe <- factor(cake$recipe)
> cake$replicate <- factor(cake$replicate)
> cake$batch <- factor(cake$batch)
> cake$temperature <- factor(cake$temperature)
> dim(cake)
[1] 270 5
> head(cake)
replicate batch recipe temperature angle
1 1 1 1 175 42
2 1 1 1 185 46
3 1 1 1 195 47
4 1 1 1 205 39
5 1 1 1 215 53
6 1 1 1 225 42
> system.time(cake.lmer <- lmer(angle ~ recipe * temperature +
(1 | replicate/batch), data = cake))
[1] 0.15 0.00 0.16 NA NA
> summary(cake.lmer)
Linear mixed-effects model fit by REML
Formula: angle ~ recipe * temperature + (1 | replicate/batch)
Data: cake
AIC BIC logLik MLdeviance REMLdeviance
1635 1707 -797.7 1638 1595
Random effects:
Groups Name Variance Std.Dev.
batch:replicate (Intercept) 3.7384 1.9335
replicate (Intercept) 38.2278 6.1829
Residual 20.4613 4.5234
number of obs: 270, groups: batch:replicate, 45; replicate, 15
Fixed effects:
Estimate Std. Error t value
(Intercept) 29.1333 2.0401 14.281
recipe2 -2.2667 1.7963 -1.262
recipe3 -1.2000 1.7963 -0.668
temperature185 2.4000 1.6517 1.453
temperature195 1.6667 1.6517 1.009
temperature205 4.4000 1.6517 2.664
temperature215 9.5333 1.6517 5.772
temperature225 5.9333 1.6517 3.592
recipe2:temperature185 0.1333 2.3359 0.057
recipe3:temperature185 -1.4000 2.3359 -0.599
recipe2:temperature195 3.2000 2.3359 1.370
recipe3:temperature195 2.1333 2.3359 0.913
recipe2:temperature205 0.8667 2.3359 0.371
recipe3:temperature205 -1.4667 2.3359 -0.628
recipe2:temperature215 -1.9333 2.3359 -0.828
recipe3:temperature215 -3.0667 2.3359 -1.313
recipe2:temperature225 2.4667 2.3359 1.056
recipe3:temperature225 1.8667 2.3359 0.799
Correlation of Fixed Effects:
(Intr) recip2 recip3 tmp185 tmp195 tmp205 tmp215 tmp225 r2:185
recipe2 -0.440
recipe3 -0.440 0.500
tempertr185 -0.405 0.460 0.460
tempertr195 -0.405 0.460 0.460 0.500
tempertr205 -0.405 0.460 0.460 0.500 0.500
tempertr215 -0.405 0.460 0.460 0.500 0.500 0.500
tempertr225 -0.405 0.460 0.460 0.500 0.500 0.500 0.500
rcp2:tmp185 0.286 -0.650 -0.325 -0.707 -0.354 -0.354 -0.354 -0.354
rcp3:tmp185 0.286 -0.325 -0.650 -0.707 -0.354 -0.354 -0.354 -0.354 0.500
rcp2:tmp195 0.286 -0.650 -0.325 -0.354 -0.707 -0.354 -0.354 -0.354 0.500
rcp3:tmp195 0.286 -0.325 -0.650 -0.354 -0.707 -0.354 -0.354 -0.354 0.250
rcp2:tmp205 0.286 -0.650 -0.325 -0.354 -0.354 -0.707 -0.354 -0.354 0.500
rcp3:tmp205 0.286 -0.325 -0.650 -0.354 -0.354 -0.707 -0.354 -0.354 0.250
rcp2:tmp215 0.286 -0.650 -0.325 -0.354 -0.354 -0.354 -0.707 -0.354 0.500
rcp3:tmp215 0.286 -0.325 -0.650 -0.354 -0.354 -0.354 -0.707 -0.354 0.250
rcp2:tmp225 0.286 -0.650 -0.325 -0.354 -0.354 -0.354 -0.354 -0.707 0.500
rcp3:tmp225 0.286 -0.325 -0.650 -0.354 -0.354 -0.354 -0.354 -0.707 0.250
r3:185 r2:195 r3:195 r2:205 r3:205 r2:215 r3:215 r2:225
recipe2
recipe3
tempertr185
tempertr195
tempertr205
tempertr215
tempertr225
rcp2:tmp185
rcp3:tmp185
rcp2:tmp195 0.250
rcp3:tmp195 0.500 0.500
rcp2:tmp205 0.250 0.500 0.250
rcp3:tmp205 0.500 0.250 0.500 0.500
rcp2:tmp215 0.250 0.500 0.250 0.500 0.250
rcp3:tmp215 0.500 0.250 0.500 0.250 0.500 0.500
rcp2:tmp225 0.250 0.500 0.250 0.500 0.250 0.500 0.250
rcp3:tmp225 0.500 0.250 0.500 0.250 0.500 0.250 0.500 0.500
> system.time(cake.lmer2 <- lmer2(angle ~ recipe * temperature +
(1 | replicate/batch), data = cake))
[1] 0.08 0.00 0.06 NA NA
> summary(cake.lmer2)
Linear mixed-effects model fit by REML
AIC BIC logLik MLdeviance REMLdeviance
1643 1715 -801.7 1647 1603
Random effects:
Groups Name Variance Std.Dev.
batch:replicate (Intercept) 2.2454e-06 0.0014985
replicate (Intercept) 3.9195e+01 6.2605709
Residual 2.3099e+01 4.8061038
Number of obs: 270, groups: batch:replicate, 45; replicate, 15
Fixed effects:
Estimate Std. Error t value
(Intercept) 29.1333 2.0379 14.296
recipe2 -2.2667 1.7549 -1.292
recipe3 -1.2000 1.7549 -0.684
temperature185 2.4000 1.7549 1.368
temperature195 1.6667 1.7549 0.950
temperature205 4.4000 1.7549 2.507
temperature215 9.5333 1.7549 5.432
temperature225 5.9333 1.7549 3.381
recipe2:temperature185 0.1333 2.4819 0.054
recipe3:temperature185 -1.4000 2.4819 -0.564
recipe2:temperature195 3.2000 2.4819 1.289
recipe3:temperature195 2.1333 2.4819 0.860
recipe2:temperature205 0.8667 2.4819 0.349
recipe3:temperature205 -1.4667 2.4819 -0.591
recipe2:temperature215 -1.9333 2.4819 -0.779
recipe3:temperature215 -3.0667 2.4819 -1.236
recipe2:temperature225 2.4667 2.4819 0.994
recipe3:temperature225 1.8667 2.4819 0.752
Correlation of Fixed Effects:
(Intr) recip2 recip3 tmp185 tmp195 tmp205 tmp215 tmp225 r2:185
recipe2 -0.431
recipe3 -0.431 0.500
tempertr185 -0.431 0.500 0.500
tempertr195 -0.431 0.500 0.500 0.500
tempertr205 -0.431 0.500 0.500 0.500 0.500
tempertr215 -0.431 0.500 0.500 0.500 0.500 0.500
tempertr225 -0.431 0.500 0.500 0.500 0.500 0.500 0.500
rcp2:tmp185 0.304 -0.707 -0.354 -0.707 -0.354 -0.354 -0.354 -0.354
rcp3:tmp185 0.304 -0.354 -0.707 -0.707 -0.354 -0.354 -0.354 -0.354 0.500
rcp2:tmp195 0.304 -0.707 -0.354 -0.354 -0.707 -0.354 -0.354 -0.354 0.500
rcp3:tmp195 0.304 -0.354 -0.707 -0.354 -0.707 -0.354 -0.354 -0.354 0.250
rcp2:tmp205 0.304 -0.707 -0.354 -0.354 -0.354 -0.707 -0.354 -0.354 0.500
rcp3:tmp205 0.304 -0.354 -0.707 -0.354 -0.354 -0.707 -0.354 -0.354 0.250
rcp2:tmp215 0.304 -0.707 -0.354 -0.354 -0.354 -0.354 -0.707 -0.354 0.500
rcp3:tmp215 0.304 -0.354 -0.707 -0.354 -0.354 -0.354 -0.707 -0.354 0.250
rcp2:tmp225 0.304 -0.707 -0.354 -0.354 -0.354 -0.354 -0.354 -0.707 0.500
rcp3:tmp225 0.304 -0.354 -0.707 -0.354 -0.354 -0.354 -0.354 -0.707 0.250
r3:185 r2:195 r3:195 r2:205 r3:205 r2:215 r3:215 r2:225
recipe2
recipe3
tempertr185
tempertr195
tempertr205
tempertr215
tempertr225
rcp2:tmp185
rcp3:tmp185
rcp2:tmp195 0.250
rcp3:tmp195 0.500 0.500
rcp2:tmp205 0.250 0.500 0.250
rcp3:tmp205 0.500 0.250 0.500 0.500
rcp2:tmp215 0.250 0.500 0.250 0.500 0.250
rcp3:tmp215 0.500 0.250 0.500 0.250 0.500 0.500
rcp2:tmp225 0.250 0.500 0.250 0.500 0.250 0.500 0.250
rcp3:tmp225 0.500 0.250 0.500 0.250 0.500 0.250 0.500 0.500
> sessionInfo()
R version 2.4.1 (2006-12-18)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
lme4 Matrix lattice
"0.9975-11" "0.9975-8" "0.14-16"
More information about the R-sig-mixed-models
mailing list