[R] code for mixed model in R?

Ben Bolker bbolker at gmail.com
Fri Feb 24 15:23:09 CET 2012


jurgen_vercauteren <jurgen_vercauteren <at> hotmail.com> writes:

> I am analysing my data wit a mixed model. I used SAS but I want to redo the
> same analysis in R. Here the SAS code and what I wrote in R. It seems to
> work but the results are not the same. I don't know how to specify the class
> variable in R or specify the variance matrix. Can you please help me?
> 
> Thanks
> Jurgen
> 
> ## SAS:
> proc glimmix data=trend method=RSPL;
>    class pid;
>    model mdrfinal (event = '1') = time therapy comment / dist=binary
> link=logit solution cl;
>    random intercept / subject=pid type=un;
> run;
> 
> ## R:
> model_GLMM<- glmmPQL(mdrfinal ~ time + therapy + comment, data = data,
> family = binomial, random = ~1| time)
> summary(model_GLMM) 

  This question would probably get a better reception on the r-sig-mixed-models
<at> r-project.org mailing list.

  I think you want random = ~1|pid , although with an unstructured
variance-covariance matrix you may want random=~factor(time)|pid --
keep in mind that's what on the RHS of the bar is a grouping factor,
the LHS of the bar is the random effect(s) term.

  If you do ~1|pid you'll get a compound-symmetry model with positive rho;
if ftime is a factor variable and you do ~ftime|pid you'll get an
unstructured matrix.



More information about the R-help mailing list