[R] Effects library LSM decimal place errors
Nieves Felipe
nieves.felipe at gmail.com
Fri Jul 16 05:41:41 CEST 2010
G'day,
I'm calculating LSM for the following model, and am finding that R and
SAS give different answers.
Whilst the error is at the second or third decimal, the percentage
error can be quite large.
I'm using the effects library (Version: 2.0-10) on R 2.11.1 in the
following manner:
options(contrasts=c("contr.helmert","contr.poly"))
aov2<-glm(log(y+.01)~covar+var1:var3+var2:var3+var1+var2+var3,data=mydat,weights=w)
mod<-effect("var1",aov2)
cbind(mod$fit, mod$se)
R gives the following values for var1:
LSM SE
-4.080362 0.06692946
-4.221714 0.10233130
The same problem gives the following values in SAS:
var1 ln_y Error
-4.10699540 0.06879095
-4.21943501 0.10096482
The following is my SAS code:
PROC IMPORT OUT= WORK.dat
DATAFILE= "C:\Documents and Settings\nxf\Desktop\mydat.xls"
DBMS=EXCEL REPLACE; GETNAMES=YES;
MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES;
RUN;
proc contents data=dat;
run;
data dum;
set dat;
ln_y = log(y+0.01);
run;
proc glm data=dum;
title2 'test';
weight w;
class var1 var2 var3;
model ln_y = covar var1 var2 var3 var1*var3 var2*var3;
lsmeans var1 var2 var3 var1*var3 var2*var3 /out=LSMeffect stderr;
run;quit;
proc print data=LSMeffect;
run;
proc export data=LSMeffect outfile='C:\Documents and
Settings\nxf\Desktop\sas1.xls'
DBMS=EXCEL2000 replace;
run;
I've been using R for about 4 months, apologies if this has a simple
solution I'm unaware of. I'm completely new to SAS.
Many thanks in advance,
Nieves Felipe.
More information about the R-help
mailing list