SCM

SCM Repository

[matrix] Annotation of /pkg/tests/lmer.R
ViewVC logotype

Annotation of /pkg/tests/lmer.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 820 - (view) (download)

1 : bates 769 library(Matrix)
2 : bates 716 options(show.signif.stars = FALSE)
3 :    
4 :     (fm1 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
5 :     OrchardSprays))
6 :     (fm2 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
7 :     OrchardSprays, method = "ML"))
8 :    
9 :     ## should produce a warning but fit by REML
10 :     (fm1 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
11 :     OrchardSprays, method = "AGQ"))
12 :    
13 :     ## generalized linear mixed model
14 :     (fm3 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
15 :     OrchardSprays, poisson(), method = "PQL"))
16 :    
17 :     ## should use PQL
18 :     (fm3 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
19 :     OrchardSprays, poisson()))
20 :    
21 : bates 752 ## Laplace approximation
22 : bates 818 #(fm4 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),
23 :     # OrchardSprays, poisson(), method = "Laplace"))
24 : bates 755
25 : bates 793 if (isTRUE(try(data(Contraception, package = 'mlmRev')) ==
26 : bates 820 'Contraception') && exists("nlminb", mode = "function")) {
27 : bates 797 print(fm1 <- lmer(use ~ urban + age + livch + (1 | district),
28 :     Contraception, binomial))
29 :     print(system.time(fm1 <- lmer(use ~ urban + age + livch + (1 | district),
30 :     Contraception, binomial), gc = TRUE))
31 :     print(fm2 <- lmer(use ~ urban + age + livch + (1 | district),
32 :     Contraception, binomial, method = 'Laplace'))
33 :     print(system.time(fm2 <- lmer(use ~ urban + age + livch + (1 | district),
34 :     Contraception, binomial, method = 'Laplace'),
35 :     gc = TRUE))
36 :     print(fm2a <- lmer(use ~ urban + age + livch + (1 | district),
37 :     Contraception, binomial, method = 'AGQ'))
38 :     print(system.time(fm2a <- lmer(use ~ urban + age + livch + (1 | district),
39 :     Contraception, binomial, method = 'AGQ'),
40 :     gc = TRUE))
41 :     print(fm3 <- lmer(use ~ urban + age + livch + (urban | district),
42 : bates 793 Contraception, binomial))
43 : bates 797 print(fm4 <- lmer(use ~ urban + age + livch + (urban | district),
44 : bates 793 Contraception, binomial, method = 'Laplace'))
45 :     }
46 : bates 820 if (require('MASS', quietly = TRUE) && exists("nlminb", mode = "function")) {
47 : bates 793 bacteria$wk2 <- bacteria$week > 2
48 :     contrasts(bacteria$trt) <-
49 :     structure(contr.sdif(3),
50 :     dimnames = list(NULL, c("diag", "encourage")))
51 : bates 797 print(fm5 <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial))
52 :     print(system.time(fm5 <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial),
53 :     gc = TRUE))
54 :     print(fm6 <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial,
55 : bates 793 method = 'Laplace'))
56 : bates 797 print(system.time(fm6 <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial,
57 :     method = 'Laplace'), gc = TRUE))
58 :     print(fm6a <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial,
59 : bates 793 method = 'AGQ'))
60 : bates 797 print(system.time(fm6a <- lmer(y ~ trt + wk2 + (1|ID), bacteria, binomial,
61 :     method = 'AGQ'), gc = TRUE))
62 : bates 793 }
63 :     q('no')
64 :    

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge