[R-sig-ME] lmer and SAS proc mixed
bates at stat.wisc.edu
Tue May 26 20:44:21 CEST 2009
On Tue, May 26, 2009 at 1:25 PM, Julia Liu <liujulia7 at gmail.com> wrote:
> Prof. Bates:
> I am learning mixed-effect model, and I am building a simple mixed
> model using R lmer() function. Just for testing, I ran the same model
> using SAS proc mixed, and found that the estimates are different.
> The R code is
> lmer(y ~ x1 + x2+ x3+ x4+ x5 + (1 + x1 | pid), data=dt)
> The SAS code is:
> %let fvars=x1 x2 x3 x4 x5;
> proc mixed data=dt;
> class pid;
> model y= &fvars / solution outp=predicted;
> random intercept x1/sub=pid solution;
> ods output SolutionF=fbeta;
> ods output SolutionR=rbeta;
> I know that both lmer and proc mixed uses REML, so I am surprised to
> see the estimates come out different.
> I also tried the model with only intercept randomized (ie. lmer(y ~ x1
> + x2+ x3+ x4+ x5 + (1| pid), data=dt), this time, the estimates from R
> and SAS are the same. I do not know why. I know that you are an expert
> in mixed-effect model, and I was wondering whether you could shed some
> light on the difference between lmer and proc mixed.
I know what the lmer model fits but I don't know SAS PROC MIXED that
well so I can't tell you what model the SAS code would fit. I have
sent a copy of this reply to the R-SIG-Mixed-Models mailing list in
the hopes that someone reading that list could say what model would be
The fact that the estimates coincide when you remove the random effect
for x1 indicates to me that the variance-covariance structure of the
model description for SAS may be other than the general positive
definite structure (which in SAS is called "unconstrained", I believe,
despite the fact that the matrix is subject to several constraints)
used in lmer.
> I can send you the data if you let me, it is about 263KB in a .csv format.
> Thank you very much,
More information about the R-sig-mixed-models