Hi All,

I am trying to shift from running mixed models in SAS using PROC MIXED
to using lme4 package in R. In trying to match the coefficients of R
output to that of SAS output, I came across this problem.

The dataset I am using is this one:

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect034.htm

If I run the following code:

proc mixed data=rc method=ML covtest;
class Batch;
model Y = Month / s;
random Int Month / type=cs sub=Batch s;
run;

The Fixed effect coefficients match with that of R. But the random
effect does not. Here is the R code:

rc <- read.table('rc.csv', sep = ',', header=T, na.strings=".")

m1 <- lmer(formula = Y ~ Month + (Month|Batch), data = rc, REML = F)

summary(m1)

fixef(m1)

ranef(m1)

But if I change the SAS code as follows:

proc mixed data=rc method=ML covtest;
class Batch;
model Y = Month / s;
random Int / type=cs sub=Batch s;
run;

and the R code as follows:

m2 <- lmer(formula = Y ~ Month + (1|Batch), data = rc, REML = F)

summary(m2)

fixef(m2)

ranef(m2)

both fixed and random effect coefficients match. I am unable to
understand this discrepancy. Am I wrongly specifying the model in the
first case?

It would be helpful if someone can throw some light on this.

Regards,
Indrajit

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to