Exam9.1: Example 9.1 from Generalized Linear Mixed Models: Modern...

Exam9.1R Documentation

Example 9.1 from Generalized Linear Mixed Models: Modern Concepts, Methods and Applications by Walter W. Stroup (p-273)

Description

Exam9.1 One-way random effects only model

Author(s)

  1. Muhammad Yaseen (myaseen208@gmail.com)

  2. Adeela Munawar (adeela.uaf@gmail.com)

References

  1. Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.

See Also

DataSet9.1

Examples


data(DataSet9.1)
DataSet9.1$a <- factor(x = DataSet9.1$a)

##---Random effects model
library(lmerTest)
Exam9.1lmer <- lmer( y ~ 1 + (1|a), data = DataSet9.1)
summary(Exam9.1lmer)

##---fixed effects model
Exam9.1lmer2 <- lm(y ~ a, data = DataSet9.1)
summary(Exam9.1lmer2)

 #---------------------------------------------------
 ## Over all mean narrow( page # 274)
 #---------------------------------------------------
library(emmeans)
library(phia)
list9.1 <- list(a = c( "1" = 1/12,"2" = 1/12
                      , "3" = 1/12,"4" = 1/12
                      , "5" = 1/12,"6" = 1/12
                      , "7" = 1/12,"8" = 1/12
                      , "9" = 1/12,"10" = 1/12
                      , "11" = 1/12,"12" = 1/12
                      ))
phia::testFactors(model = Exam9.1lmer2, levels = list9.1)


#---BLUP Estimates (Table 9.1)
coef <- unlist(ranef(Exam9.1lmer))
BLUPa <- NULL
for( i in 1:length(coef)) {
  BLUPa[i] <- (mean(DataSet9.1$y)+coef[i])
  }
print(BLUPa)


StroupGLMM documentation built on Oct. 2, 2024, 1:07 a.m.