Example 8.4 from Generalized Linear Mixed Models: Modern Concepts, Methods and Applications by Walter W. Stroup (p-259)
Source:R/Exam8.4.R
Exam8.4.Rd
Exam8.4 Multifactor treatment and Multilevel design structures
References
Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.
Author
Muhammad Yaseen (myaseen208@gmail.com)
Adeela Munawar (adeela.uaf@gmail.com)
Examples
data(DataSet8.4)
DataSet8.4$block <- factor(x = DataSet8.4$block)
DataSet8.4$a <- factor(x = DataSet8.4$a)
DataSet8.4$b <- factor(x = DataSet8.4$b)
library(lmerTest)
Exam8.4lmer <-
lmer(
y ~ a + b %in% a +
(1|block) + (1|block:a) + (1|block:b)
, data = DataSet8.4
)
#> boundary (singular) fit: see help('isSingular')
anova(Exam8.4lmer, ddf = "Kenward-Roger")
#> Type III Analysis of Variance Table with Kenward-Roger's method
#> Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> a 35.89 17.946 2 14.648 1.7568 0.20707
#> a:b 477.15 79.525 6 13.573 7.4008 0.00114 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
library(emmeans)
emmeans(object = Exam8.4lmer, specs = ~a|b)
#> NOTE: A nesting structure was detected in the fitted model:
#> b %in% a
#> a = 1, b = 1:
#> emmean SE df lower.CL upper.CL
#> 9.2 2.39 26.3 4.29 14.1
#>
#> a = 2, b = 1:
#> emmean SE df lower.CL upper.CL
#> 14.3 2.39 26.3 9.42 19.2
#>
#> a = 3, b = 1:
#> emmean SE df lower.CL upper.CL
#> 12.8 2.39 26.3 7.92 17.7
#>
#> a = 1, b = 2:
#> emmean SE df lower.CL upper.CL
#> 28.7 2.39 26.3 23.79 33.6
#>
#> a = 2, b = 2:
#> emmean SE df lower.CL upper.CL
#> 24.5 2.39 26.3 19.55 29.4
#>
#> a = 3, b = 2:
#> emmean SE df lower.CL upper.CL
#> 21.1 2.39 26.3 16.14 26.0
#>
#> a = 1, b = 3:
#> emmean SE df lower.CL upper.CL
#> 27.6 2.39 26.3 22.65 32.5
#>
#> a = 2, b = 3:
#> emmean SE df lower.CL upper.CL
#> 25.3 2.39 26.3 20.40 30.2
#>
#> a = 3, b = 3:
#> emmean SE df lower.CL upper.CL
#> 18.9 2.39 26.3 13.95 23.8
#>
#> Degrees-of-freedom method: kenward-roger
#> Confidence level used: 0.95