I'm trying to convert the following SAS code in R to get the same result that I get from SAS. Here is the SAS code:
DATA plants;
INPUT sample $ treatmt $ y ;
cards;
1 trt1 6.426264755
1 trt1 6.95419631
1 trt1 6.64385619
1 trt2 7.348728154
1 trt2 6.247927513
1 trt2 6.491853096
2 trt1 2.807354922
2 trt1 2.584962501
2 trt1 3.584962501
2 trt2 3.906890596
2 trt2 3
2 trt2 3.459431619
3 trt1 2
3 trt1 4.321928095
3 trt1 3.459431619
3 trt2 3.807354922
3 trt2 3
3 trt2 2.807354922
4 trt1 0
4 trt1 0
4 trt1 0
4 trt2 0
4 trt2 0
4 trt2 0
;
RUN;
PROC MIXED ASYCOV NOBOUND DATA=plants ALPHA=0.05 method=ML;
CLASS sample treatmt;
MODEL y = treatmt ;
RANDOM int treatmt/ subject=sample ;
RUN;
I get the following covariance estimates from SAS:
Intercept sample ==> 5.5795 Treatmt sample ==> -0.08455 Residual ==> 0.3181
I tried the following in R, but I get different results.
s=as.factor(sample)
lmer(y~ 1+treatmt+(1|treatmt:s),REML=FALSE)
I don't know if you'll be able to get the exact results from SAS to R, but I was able to get close by dealing with
contrast
as outlined here :lmer for SAS PROC MIXED Users : page 6
dput :
Current Code :
Current Output :