[R-sig-ME] lmer and SAS proc mixed

Viechtbauer Wolfgang (STAT) Wolfgang.Viechtbauer at STAT.unimaas.nl
Tue May 26 21:10:55 CEST 2009


Try:

proc mixed data=dt;
	class pid;
	model y= &fvars / solution outp=predicted;
	random intercept x1/sub=pid type=un solution;
	ods output SolutionF=fbeta;
	ods output SolutionR=rbeta;

(note the addition of type=un on the line starting with random). I believe type=vc is the default, which does not allow the random intercept and slope to be correlated (which lmer does).

Best,

-- 
Wolfgang Viechtbauer
 Department of Methodology and Statistics
 University of Maastricht, The Netherlands
 http://www.wvbauer.com/



----Original Message----
From: r-sig-mixed-models-bounces at r-project.org
[mailto:r-sig-mixed-models-bounces at r-project.org] On Behalf Of Douglas
Bates Sent: Tuesday, May 26, 2009 20:44 To: Julia Liu
Cc: R-mixed models mailing list
Subject: Re: [R-sig-ME] lmer and SAS proc mixed

> 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;
>> run;
>> quit;
>> =========================
> 
>> 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 fit.   
> 
> 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,
>> sincerely,
>> Julia




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