Exam3.9: Example 3.9 from Generalized Linear Mixed Models: Modern...

Exam3.9R Documentation

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

Description

Exam3.9 used to differentiate conditional and marginal binomial models with and without interaction for S2 variable.

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

DataSet3.2

Examples

#-----------------------------------------------------------------------------------
## Binomial conditional GLMM without interaction, logit link
#-----------------------------------------------------------------------------------
library(MASS)
DataSet3.2$trt <- factor( x  =  DataSet3.2$trt )
DataSet3.2$loc <- factor( x  =  DataSet3.2$loc )

Exam3.9.fm1   <-
  glmmPQL(
      fixed    =  S2/Nbin~trt
    , random   = ~1|loc
    , family   =  quasibinomial(link = "logit")
    , data     =  DataSet3.2
    , niter    = 10
    , verbose  = TRUE
  )
summary(Exam3.9.fm1)
library(parameters)
model_parameters(Exam3.9.fm1)

#-------------------------------------------------------------
##  treatment means
#-------------------------------------------------------------
library(emmeans)
emmeans(object = Exam3.9.fm1, specs = ~trt, type = "response")
emmeans(object = Exam3.9.fm1, specs = ~trt, type = "link")
emmeans(object = Exam3.9.fm1, specs = ~trt, type = "logit")

##--- Normal Approximation
library(nlme)
Exam3.9fm2 <-
  lme(
      fixed       = S2/Nbin~trt
    , data        = DataSet3.2
    , random      = ~1|loc
    , method      = c("REML", "ML")[1]
  )

Exam3.9fm2
model_parameters(Exam3.9fm2)

emmeans(object  = Exam3.9fm2, specs = ~trt)


##---Binomial GLMM with interaction
Exam3.9fm3   <-
  glmmPQL(
      fixed       =  S2/Nbin~trt
    , random      = ~1|trt/loc
    , family      =  quasibinomial(link = "logit")
    , data        =  DataSet3.2
    , niter = 10
    , verbose = TRUE
  )
summary(Exam3.9fm3)
model_parameters(Exam3.9fm3)
emmeans(object = Exam3.9fm3, specs = ~trt)


##---Binomial Marginal GLMM(assuming compound symmetry)
Exam3.9fm4   <-
  glmmPQL(
      fixed       =  S2/Nbin~trt
    , random      = ~1|loc
    , family      =  quasibinomial(link = "logit")
    , data        =  DataSet3.2
    , correlation =  corCompSymm(form = ~1|loc)
    , niter       = 10
    , verbose     = TRUE
  )
summary(Exam3.9fm4)
model_parameters(Exam3.9fm4)
emmeans(object  = Exam3.9fm4, specs  = ~trt)


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