Hi experts, I have just about started to use R (after using SAS for more than 5 years) and still finding my way...I have been trying to replicate PROC MIXED results in LMER but noticed that the estimates are coming different. My SAS code is as follows (trying to randomise X2 and Intercept): PROC MIXED DATA = <DATASET NAME> NAMELEN=100 METHOD=REML MAXITER=1000; CLASS GEOGRAPHY; MODEL y = X1 X2 X3/SOLUTION; RANDOM INTERCEPT X2/SOLUTION SUBJECT = GEOGRAPHY; ODS OUTPUT SOLUTIONR=RANDOM_EFFECT; ODS OUTPUT SOLUTIONF= FIXED_EFFECT; RUN; the equivalent code that I was writting in R is as follows: testdata <- read.csv("adstest.csv",header=TRUE,sep=",") attach(testdata) library(lme4) options(contrasts = c(factor = "contr.SAS",ordered = "contr.poly")) lmm.2=lmer(y~X1+X2+X3 + (X2|Geography),REML=TRUE,data=bigads) I am not sure if I have got the R script/options correct...but I seem to be getting different estimates from the same dataset.... any help on this would be highly appreciated!!!! -- View this message in context: http://r.789695.n4.nabble.com/LMER-vs-PROC-MIXED-estimates-tp4648653.html Sent from the R help mailing list archive at Nabble.com.
On Nov 6, 2012, at 7:00 PM, sandip1006 wrote:> Hi experts, > > I have just about started to use R (after using SAS for more than 5 years) > and still finding my way...I have been trying to replicate PROC MIXED > results in LMER but noticed that the estimates are coming different.Better practice would be to spell the R functions with proper capitalization, in this case none.> > My SAS code is as follows (trying to randomise X2 and Intercept): > PROC MIXED DATA = <DATASET NAME> NAMELEN=100 METHOD=REML MAXITER=1000; > CLASS GEOGRAPHY; > MODEL y = X1 X2 X3/SOLUTION; > RANDOM INTERCEPT X2/SOLUTION SUBJECT = GEOGRAPHY; > ODS OUTPUT SOLUTIONR=RANDOM_EFFECT; > ODS OUTPUT SOLUTIONF= FIXED_EFFECT; > RUN; > > the equivalent code that I was writting in R is as follows: > testdata <- read.csv("adstest.csv",header=TRUE,sep=",") > attach(testdata)Why are you attach()-ing 'testdata'?> library(lme4) > options(contrasts = c(factor = "contr.SAS",ordered = "contr.poly"))> lmm.2=lmer(y~X1+X2+X3 + (X2|Geography),REML=TRUE,data=bigads) > > I am not sure if I have got the R script/options correct...but I seem to be > getting different estimates from the same dataset....Why are you giving a different data argument to 'lmer' than the dataframe you read in from disk? And you should at the very least show the output of str() on both datasets.> any help on this would be highly appreciated!!!!A more appropriate place to post this (with better description of the dataset) would be the Mixed Models SIG. -- David Winsemius, MD Alameda, CA, USA
Hi David, Thanks for the reply. sorry for typo in the R script ...what I meant to write was testdata <- read.csv("adstest.csv",header=TRUE,sep=",") attach(testdata) library(lme4) options(contrasts = c(factor = "contr.SAS",ordered = "contr.poly")) lmm.2=lmer(y~X1+X2+X3 + (X2|Geography),REML=TRUE,data=testdata) not sure if attaching the dataset causes any problem. Also, I would take your suggestion and post this in Mixed Models SIG. Regards, Sandip -- View this message in context: http://r.789695.n4.nabble.com/LMER-vs-PROC-MIXED-estimates-tp4648653p4648671.html Sent from the R help mailing list archive at Nabble.com.