Exam7.2 | R Documentation |
Exam7.2 explains multifactor models with some factors qualitative and some quantitative(Equal slopes ANCOVA)
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.
@seealso
DataSet7.2
library(emmeans)
library(car)
library(ggplot2)
data(DataSet7.2)
DataSet7.2$trt <- factor( x = DataSet7.2$trt )
##----ANCOVA(Equal slope Model)
Exam7.2fm1 <- aov(formula = y ~ trt*x, data = DataSet7.2)
car::Anova(mod = Exam7.2fm1 , type = "III")
##---ANCOVA(without interaction because of non significant slope effect)
Exam7.2fm2 <- aov(formula = y ~ trt + x, data = DataSet7.2)
car::Anova(mod = Exam7.2fm2 , type = "III")
##---Ls means for 2nd model
emmeans(object = Exam7.2fm2, specs = ~trt)
##---Anova without covariate
Exam7.2fm3 <- aov(formula = y ~ trt, data = DataSet7.2)
car::Anova(mod = Exam7.2fm3, type = "III")
##---Ls means for 3rd model
emmeans(object = Exam7.2fm3, specs = ~trt)
##---Box Plot of Covariate by treatment
Plot <-
ggplot(
data = DataSet7.2
, mapping = aes(x = factor(trt), y = x)
) +
geom_boxplot(width = 0.5) +
coord_flip() +
geom_point() +
stat_summary(
fun = "mean"
, geom = "point"
, shape = 23
, size = 2
, fill = "red"
) +
theme_bw() +
ggtitle("Covariate by treatment Box Plot") +
xlab("Treatment")
print(Plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.