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

Description Author(s) References See Also Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#-----------------------------------------------------------------------------------
## 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
  # , weights
  # , control
    , niter    = 10
    , verbose  = TRUE
    # , ...
  )
summary(Exam3.9.fm1)

#-------------------------------------------------------------
##  treatment means
#-------------------------------------------------------------
library(lsmeans)
(Lsm3.9fm1   <-
  lsmeans::lsmeans(
      object  = Exam3.9.fm1
    , specs   = "trt"
    , link=TRUE
    # , ...
  )
)
##--- Normal Approximation
library(nlme)
Exam3.9fm2 <-
  lme(
      fixed       = S2/Nbin~trt
    , data        = DataSet3.2
    , random      = ~1|loc
    , weights     = NULL
  # , subset
    , method      = "REML" #c("REML", "ML")
    , na.action   = na.fail
  # , control     = list()
    , contrasts   = NULL
    , keep.data   = TRUE
  )
(Lsm3.9fm2    <-
  lsmeans::lsmeans(
      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
  # , weights
  # , control
    , niter = 10
    , verbose = TRUE
    # , ...
  )
summary(Exam3.9fm3)
(Lsm3.9fm3    <-
  lsmeans::lsmeans(
      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)
  # , weights
  # , control
    , niter       = 10
    , verbose     = TRUE
  # , ...
  )
summary(Exam3.9fm4)
(Lsm3.9fm4  <-
  lsmeans::lsmeans(
      object  = Exam3.9fm4
    , specs   = "trt"
    # , ...
  )
)

StroupGLMM documentation built on May 2, 2019, 9:42 a.m.