Exam7.3: Example 7.3 from Generalized Linear Mixed Models: Modern...

Exam7.3R Documentation

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

Description

Exam7.3 explains multifactor models with some factors qualitative and some quantitative(Unequal slopes ANCOVA)

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.

@seealso DataSet7.3

Examples


library(car)
library(ggplot2)
library(emmeans)
data(DataSet7.3)

DataSet7.3$trt <- factor(x = DataSet7.3$trt )

##----ANCOVA(Unequal slope Model)
Exam7.3fm1 <- aov(formula = y ~ trt*x, data = DataSet7.3)
car::Anova( mod = Exam7.3fm1 , type = "III")

Plot <-
   ggplot(
          data    = DataSet7.3
        , 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)

##----ANCOVA(Unequal slope Model without intercept at page 224)
Exam7.3fm2 <- lm(formula = y ~ 0 + trt/x, data = DataSet7.3)
summary(Exam7.3fm2)
library(parameters)
model_parameters(Exam7.3fm2)

##--Lsmeans treatment at x=7 & 12 at page 225
emmeans(object = Exam7.3fm2, specs = ~trt|x, at = list(x = c(7, 12)))


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