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
Run the code above in your browser using DataLab