Example 9.4 from Generalized Linear Mixed Models: Modern Concepts, Methods and Applications by Walter W. Stroup (p-288)
Source:R/Exam9.4.R
Exam9.4.Rd
Exam9.4 Relationship between BLUP and Fixed Effect Estimators
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(DataSet9.4)
DataSet9.4$a <- factor(x = DataSet9.4$a)
DataSet9.4$b <- factor(x = DataSet9.4$b)
library(lmerTest)
Exam9.4lmer <- lmer(y ~ a + (1|b) + (1|a/b), data = DataSet9.4)
#> Warning: unable to evaluate scaled gradient
#> Warning: Hessian is numerically singular: parameters are not uniquely determined
#> Warning: Model may not have converged with 1 eigenvalue close to zero: 4.4e-10
summary(Exam9.4lmer)
#> Linear mixed model fit by REML. t-tests use Satterthwaite's method [
#> lmerModLmerTest]
#> Formula: y ~ a + (1 | b) + (1 | a/b)
#> Data: DataSet9.4
#>
#> REML criterion at convergence: 155.2
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -1.51149 -0.48875 -0.06897 0.59000 1.38365
#>
#> Random effects:
#> Groups Name Variance Std.Dev.
#> b:a (Intercept) 6.256 2.501
#> b (Intercept) 4.024 2.006
#> a (Intercept) 2.380 1.543
#> Residual 3.647 1.910
#> Number of obs: 32, groups: b:a, 16; b, 8; a, 2
#>
#> Fixed effects:
#> Estimate Std. Error df t value Pr(>|t|)
#> (Intercept) 14.819 1.973 28.295 7.510 3.29e-08 ***
#> a2 -2.544 2.604 22.996 -0.977 0.339
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Correlation of Fixed Effects:
#> (Intr)
#> a2 -0.660
#> optimizer (nloptwrap) convergence code: 0 (OK)
#> unable to evaluate scaled gradient
#> Hessian is numerically singular: parameters are not uniquely determined
#>
library(emmeans)
emmeans(Exam9.4lmer, spec = ~a)
#> a emmean SE df lower.CL upper.CL
#> 1 14.8 1.97 83.5 10.89 18.7
#> 2 12.3 1.97 83.5 8.35 16.2
#>
#> Degrees-of-freedom method: kenward-roger
#> Confidence level used: 0.95