Exam9.2 | R Documentation |
Exam9.2 Two way random effects nested model
Muhammad Yaseen (myaseen208@gmail.com)
Adeela Munawar (adeela.uaf@gmail.com)
Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.
DataSet9.2
data(DataSet9.2)
DataSet9.2$a <- factor(x = DataSet9.2$a)
DataSet9.2$b <- factor(x = DataSet9.2$b)
library(lmerTest)
Exam9.2lmer <- lmer(y ~ (1|b/a), data = DataSet9.2)
summary(Exam9.2lmer)
Exam9.2lmer2 <- lm(y ~ a + b %in% a, data = DataSet9.2)
summary(Exam9.2lmer2)
##--- Over all mean
library(phia)
list9.2 <- list(a = c("1" = 1/7,"2" = 1/7
, "3" = 1/7,"4" = 1/7
, "5" = 1/7,"6" = 1/7
, "7" = 1/7
))
phia::testFactors(model = Exam9.2lmer2, levels = list9.2)
#---BLUP Estimates
coef <- unlist(ranef(Exam9.2lmer)$a)
BLUPa <- NULL
for(i in 1:length(coef)){
BLUPa[i] <- (mean(DataSet9.2$y) + coef[i])
}
print(BLUPa)
#---BLUP Estimates Narrow
BLUPaNar <- NULL
for( i in 1:length(coef)) {
BLUPaNar[i] <- (mean(DataSet9.2$y) + coef[i])
}
BLUPaNar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.