[R-sig-ME] different output in R and SAS for GLMM

Ben Bolker bbolker at gmail.com
Wed Dec 30 21:21:58 CET 2015


On Mon, Dec 28, 2015 at 11:56 PM, Adeela Munawar <adeela.uaf at gmail.com> wrote:
> Dear all,
>
> I am comparing the output of SAS and R for generalized linear mixed models
> with gamma family. Code for SAS are
>
> proc glimmix data=ch12_ex1 plot=residualpanel(ilink) noprofile;
>  class block a b;
>  model days=a|b / d=gamma;
>  random intercept a/subject=block;
>  lsmeans a*b / slicediff=(a b) ilink cl;
>  covtest /cl(type=plr);
>
> while I am fitting this using lme4 package as
> a<-factor(a)
> b<-factor(b)
> block<-factor(block)
>
> ModelGamma <- glmer(days~a*b+(1|block/a),family=Gamma(link = "log"))
>  lsmeans(ModelGamma,~a*b)
>
> but the results are altogether different. SAS gives 9 df while NA in R and
> least sqaure means are also different.
>
> a b   lsmean        SE      df   asymp.LCL asymp.UCL
>  1 1 3.212923 0.5677001 NA  2.100251  4.325595
>  2 1 3.229803 0.5662713 NA  2.119932  4.339675
>  3 1 3.279271 0.5688496 NA  2.164346  4.394196
>  1 2 2.499457 0.5679181 NA  1.386358  3.612556
>  2 2 3.248968 0.5659105 NA  2.139804  4.358132
>  3 2 3.563672 0.5689044 NA  2.448640  4.678705
>
> Why this happens? Please suggest.


I'm assuming that your SAS results match p. 457 of Stroup's
presentation, which is where I'm guessing you took this from ...
<http://www.csulb.edu/HealthEquity/civicrm/file?reset=1&id=5&eid=26>

The first difference in the results is that R presents the results in
a *different order* (A=1,2,3,1,2,3; B=1,1,1,2,2,2).  Here are Stroup's
results (lsmean estimate only) compared with the glmer results and
from another package (glmmTMB).  There are some small differences, but
nothing that's large enough that I would worry about it much
(especially since the standard errors are much larger than the
differences betwen the different estimates).

       Stroup   glmer glmmTMB
est1 3.2565 3.2129  3.2767
est2 3.3475 3.2298  3.3680
est3 3.3100 3.2793  3.3302
est4 2.5512 2.4995  2.5716
est5 3.3603 3.2490  3.3807
est6 3.6033 3.5637  3.6237

For the second issue, about degrees of freedom -- there is a long,
long discussion about whether computing the degrees of freedom makes
much sense in the GLMM context ...



More information about the R-sig-mixed-models mailing list