[R-sig-ME] lmer vs SAS results

Beth Holbrook bvholbi at yahoo.com
Tue Nov 23 22:11:16 CET 2010


First, let me preface this by saying I am an ecology Ph.D. student, relatively 
new to R, and even more new to mixed models, so I apologize in advance for my 
limited knowledge on this topic. (Also, I need to apologize for the length of 
this email - but I wanted to be as specific as possible).

I posted a question a few weeks ago, and received many helpful responses, so I'm 
hoping you can help me again.  The statistician on my committee has assisted me 
in setting up my analysis design; however, he is receiving different results 
using SAS than I am using lmer.  I understand that the goal of lmer is not to 
replicate results of SAS; however, I am unable to move ahead with my 
dissertation until I can provide him with a satisfactory explanation for these 
differences (I no longer have access to SAS so I need to use R as my primary 
statistical software).

My analysis design is to run a mixed model to test for the effects of prey 
movement ("preyswimy.n") and light ("lightclass") on the reaction distance 
("logrxndist") of young lake trout.  The random effect is "trial" since I 
observed several responses to prey for the same fish during each trial.

Using the lme4 package, I set up the following:

> options(contrasts = c(factor = "contr.SAS", ordered = "contr.poly"))
> lightclass <- factor(Dataset$light)
> trial <- factor(Dataset$trial)
> model1 <-lmer(logrxndist~preyswimy.n * lightclass + (1|trial), Dataset, 
>REML=FALSE)
> model2 <-lmer(logrxndist~preyswimy.n + lightclass + (1|trial), Dataset, 
>REML=FALSE)
> model3 <-lmer(logrxndist~preyswimy.n + (1|trial), Dataset, REML=FALSE)

Based on the following results, I concluded that the most appropriate model was 
model3 where lightclass was omitted.

> anova(model1, model2, model3)
Data: Dataset
Models:
model3: logrxndist ~ preyswimy.n + (1 | trial)
model2: logrxndist ~ preyswimy.n + lightclass + (1 | trial)
model1: logrxndist ~ preyswimy.n * lightclass + (1 | trial)
       Df    AIC    BIC   logLik  Chisq Chi Df Pr(>Chisq)
model3  4 214.21 229.98 -103.103                         
model2  9 215.26 250.74  -98.628 8.9494      5     0.1111
model1 14 219.15 274.35  -95.575 6.1062      5     0.2960   



In SAS, the statistician on my committee used the following code:


model1: 
proc mixed data=holbrook.bethfull method=ml;
  class preyswimy.n trial light;
  model logrxndist = light | preyswimy.n /solution;
  random trial;
  run;

model2:
proc mixed data=holbrook.bethfull method=ml;
  class preyswimy.n trial light;
  model logrxndist = light  preyswimy.n / solution;
  random trial;
  run;


model3
proc mixed data=holbrook.bethfull method=ml;
  class preyswimy.n trial;
  model logrxndist = preyswimy.n / solution ;
  random trial;
  run;

His results are as follows:
     
               AIC    BIC    -2 Log Likelihood  
model1   216.7  251.1   188.7 
model2   213.3  235.4   195.3
model3   214.2  224.0   206.2                         

Based on these results, he concluded that model2 had the lowest AIC and light 
was significant.

The lmer and SAS fixed effect parameter estimates were similar for model1, 
model2, and model3 (see below).  The lmer and SAS variance estimates for the 
random effect were the same for model3 (when light was excluded).  However, the 
variance estimates for the random effect differed in model1 and in model2.  The 
lmer results suggest that there is no random effect of "trial" in these models. 
 However, SAS results gave a larger variance estimate for the random effect of 
trial in model1 and model2.  Any ideas why that might be the case?  
     
model1 Random effects
 Groups   Variance-lmerVariance-SAS   
 trials    1.0305e-11 0.005385
 Residual        9.6697e-02 0.09126

model1 Fixed effects
                            Estimate-lmer   Estimate-SAS
(Intercept)                 2.151398   2.1448
preyswimy.nN               -0.344458   -0.3386
lightclass0.4               0.056317   0.06450
lightclass2.5               0.104469   0.1108
lightclass8                 0.074183   0.07667
lightclass55               -0.043046  -0.03805
lightclass340              -0.074705   -0.06529
preyswimy.nN:lightclass0.4 -0.257426   -0.2651
preyswimy.nN:lightclass2.5 -0.179126  -0.1808
preyswimy.nN:lightclass8   -0.058160   -0.05099
preyswimy.nN:lightclass55  -0.007468   -0.00753
preyswimy.nN:lightclass340 -0.123571   -0.1413


model2 Random effects:
GroupsVariance-lmerVariance-SAS
trial8.3902e-120.004775
Residual9.8259e-02  0.09394

model2 Fixed effects:

               Estimate-lmerEstimate-SAS
(Intercept)     2.20135   2.1975
preyswimy.nY    -0.45319   -0.4507
lightclass0.4  -0.02280-0.01755
lightclass2.5   0.02251    0.02634
lightclass8     0.04108    0.04401
lightclass55   -0.03539   -0.03229
lightclass340  -0.13272    -0.1336



model3 Random effects:
GroupsVariance-lmerVariance-SAS
trial0.00769170.007692
Residual0.0939409  0.09394

model3 Fixed effects:
  Estimate-lmerEstimate-SAS
(Intercept)2.186092.1861
preyswimy.nN  -0.46016 -0.4602


Thank you for any insight that you can provide.  Below, I've also attached a 
copy of the data in case you would like to run it yourself.

Thanks again,
Beth

Beth Holbrook
Ph.D. Candidate
University of Minnesota


Dataset

triallogrxndistpreyswimy.nlight
5220712.115943177N0.4
5220712.470557485Y0.4
5220721.902546779Y0.4
5220722.272769587Y0.4
5220731.985426474Y0.4
5220731.862131379Y0.4
5220732.275541688Y0.4
5220731.846337112Y0.4
5250712.314709693Y0.4
5250712.360025089Y0.4
5250712.344785123Y0.4
5250711.068185862Y0.4
5250712.540329475Y0.4
5250722.030599722Y0.4
5250721.848804701Y0.4
5250722.326540669Y0.4
5250732.186391216Y0.4
5250732.421603927Y0.4
5250732.381295623Y0.4
5250731.672097858Y0.4
6050761.844477176Y0.4
6050762.219060332Y0.4
6050762.518645524Y0.4
6050762.546419267Y0.4
6060712.153814864Y0.4
6060712.625106575Y0.4
6060712.369957607Y0.4
6060711.589949601N0.4
6060712.506505032Y0.4
6060721.439332694N0.4
6060721.822168079Y0.4
6220732.218010043Y0.4
6220732.299289334Y0.4
6220741.431363764N0.4
6220742.419955748Y0.4
6220752.227372442Y0.4
6220752.338057875Y0.4
6220761.643452676N0.4
6220762.260309946Y0.4
6220761.404833717N0.4
6220762.343802333Y0.4
6250712.366236124Y0.4
6250712.557867962Y0.4
6250712.452706227Y0.4
6250721.920645001Y0.4
6250721.967079734Y0.4
6250721.6599162N0.4
6250721.492760389N0.4
6250721.240549248N0.4
6250722.040206628N0.4
6250722.428134794Y0.4
5220741.860936621Y2.5
5220742.020361283N2.5
5220742.567731963Y2.5
5220751.599883072N2.5
5220761.350248018N2.5
5220762.288919606Y2.5
5220761.320146286N2.5
5230712.069668097N2.5
5230711.953759692N2.5
5230712.016197354N2.5
5230712.240549248Y2.5
5250741.620136055N2.5
5250742.160768562N2.5
5250741.498310554N2.5
5250742.431685345N2.5
5250751.855519156N2.5
6070712.357363031Y2.5
6070712.657629431Y2.5
6070712.302763708Y2.5
6070712.353723938Y2.5
6070712.584670384Y2.5
6070722.393224116Y2.5
6070721.722633923N2.5
6070721.830588669N2.5
6070721.812913357Y2.5
6070731.920645001N2.5
6070732.635081436Y2.5
6250731.859738566N2.5
6250732.418798291Y2.5
6250732.488550717Y2.5
6250732.084576278Y2.5
6250732.384353414Y2.5
6250732.489677292Y2.5
6250741.795880017N2.5
6250742.245265839Y2.5
6250742.068927612Y2.5
6250742.590841835Y2.5
6250742.5594278Y2.5
6250741.589949601N2.5
6250751.848189117Y2.5
6250751.816903839N2.5
6250751.613841822N2.5
6250752.536305872Y2.5
6250752.461948495Y2.5
6250752.456214155Y2.5
6250761.629409599N2.5
6250761.921686475N2.5
6250761.862727528N2.5
6250761.475671188N2.5
7020712.254064453Y2.5
7020712.137037455Y2.5
7020722.245759356Y2.5
7020721.773786445N2.5
7020722.639486489Y2.5
7020721.725094521N2.5
7020722.332842267Y2.5
7020721.854306042Y2.5
7020721.534026106N2.5
7020732.521268876Y2.5
7020732.176380692Y2.5
7020732.358125285Y2.5
7020731.530199698N2.5
7020731.970811611Y2.5
7020731.787460475N2.5
7020732.106870544Y2.5
7020731.447158031N2.5
7040712.317227349N2.5
7040712.039017322Y2.5
7040712.294466226Y2.5
7040712.276921132Y2.5
7040722.06483222N2.5
7040722.187802639Y2.5
7040722.267406419Y2.5
7040722.645520515Y2.5
7040721.906873535N2.5
7040731.536558443Y2.5
7040732.295347148Y2.5
7040731.671172843N2.5
7040732.118925753Y2.5
7040741.69019608N2.5
7040742.038620162N2.5
7040742.199480915Y2.5
7040741.999130541Y2.5
7040741.609594409N2.5
7040751.195899652N2.5
7040752.14113609Y2.5
7040752.032618761Y2.5
7040751.909556029Y2.5
7040751.336459734N2.5
7040751.59439255N2.5
7050731.717670503N2.5
7050732.141449773Y2.5
7050731.494154594N2.5
7050731.981818607Y2.5
7050732.292699003Y2.5
7050731.354108439N2.5
7050761.582063363N2.5
7050762.171433901Y2.5
7050761.645422269N2.5
5230721.852479994N8
5230722.324488233N8
5230721.941014244N8
5230721.465382851N8
5240712.605951158Y8
5240711.424881637N8
5240711.702430536Y8
5240722.407390904Y8
5240722.190051418Y8
5240722.326335861Y8
5240721.948901761N8
5240732.089198367Y8
5240732.562292864Y8
5240732.19893187Y8
5240732.466571072Y8
5240731.591064607N8
6040712.169380495Y8
6040712.692494408Y8
6040712.489817908Y8
6040712.390581879Y8
6040712.65571455Y8
6040721.86923172Y8
6040722.39707055Y8
6040722.110252917Y8
6040732.604226053Y8
6040732.322219295Y8
6040731.848804701Y8
6040740.995635195Y8
6040741.873901598N8
6040741.931966115N8
6040741.442479769N8
6040741.881384657N8
6040742.184975191Y8
6080711.843855423Y8
6080712.583652109Y8
6080711.978636948N8
6080712.557519232Y8
6080722.24723655Y8
6080722.348110068Y8
6080721.828015064Y8
6080722.069668097N8
6080732.338854746Y8
6080732.126456113N8
6080732.384353414Y8
6080731.723455672Y8
6260711.501059262Y8
6260712.020775488Y8
6260712.445915414Y8
6260711.399673721N8
6260722.571592383Y8
6260722.15136985Y8
6260731.71432976N8
6260732.248953615Y8
6260732.256958153Y8
6260732.358505911Y8
6260742.402089351Y8
6260741.829303773N8
6260741.751279104N8
6260741.963315511Y8
6260741.665580991N8
6260752.349471799Y8
6260752.259354927N8
6260751.911157609N8
6260751.721810615N8
6260752.276921132Y8
6260752.244029589Y8
6210752.100715087N55
6210752.220892249Y55
6210751.209515015N55
6210762.139879086Y55
6210761.804139432Y55
6210762.198106999N55
6210761.606381365Y55
6210761.894869657N55
6210761.746634199N55
6220711.710117365N55
6220711.925827575Y55
6220711.605305046N55
6220711.691081492N55
6220711.814913181N55
6220712.004321374N55
6220711.840733235N55
6220721.788168371Y55
6220722.35945602Y55
6220722.576686805Y55
6260762.055378331N55
6260761.10720997N55
6260761.994317153Y55
6260762.146748014Y55
6260761.421603927N55
6260761.374748346N55
6270711.064457989N55
6270711.981818607N55
6270711.445604203Y55
6270711.948901761Y55
6270712.118925753N55
6270711.996073654N55
6270711.08278537N55
6270712.370328008Y55
6270721.692846919Y55
6270722.320146286Y55
6270731.498310554Y55
6270731.728353782N55
6270732.229169703N55
6270731.79518459N55
6270732.75151005Y55
6270741.987666265N55
6270742.311329952Y55
6270741.830588669N55
6270742.215108581N55
6270742.237040791Y55
6270741.713490543Y55
7050712.181271772Y55
7050712.314709693Y55
7050711.563481085N55
7050711.859738566N55
7050711.892094603N55
7050722.705436047Y55
7050722.261262869Y55
7050721.506505032N55
7050721.810904281N55
7050721.563481085N55
7050721.960470778N55
7050722.394101302Y55
5210712.036628895Y340
5210712.220631019Y340
5210711.850646235Y340
5210711.978636948N340
5210711.602059991Y340
5210711.789580712N340
5210712.090610708Y340
5210710.903089987N340
5210711.915927212N340
5210712.278982117Y340
5210721.250420002Y340
5210721.875061263Y340
5210721.956648579Y340
5210721.127104798N340
5210721.049218023Y340
5210731.155336037N340
5210731.643452676N340
5210731.004321374N340
5210731.660865478N340
5210742.017867719N340
5210742.103119254Y340
5210741.779596491Y340
5210742.054995862Y340
5210741.017033339N340
5210741.365487985N340
5210742.046104787Y340
5210741.705863712N340
5210741.501059262N340
5210751.944482672Y340
5210751.586587305N340
5210751.243038049N340
5210751.994756945Y340
5210762.336259552Y340
5210762.499961866Y340
5210761.737192643Y340
5210762.490941205Y340
5210762.089198367N340
5210761.903089987Y340
6050732.701395269Y340
6050731.574031268N340
6050731.736396502Y340
6050731.103803721N340
6050732.04453976N340
6050731.547774705N340
6050741.722633923N340
6050742.017867719N340
6050742.126131407N340
6050742.329194415Y340
6050742.033021445Y340
6050742.299725154N340
6050742.269979677Y340
6050741.715167358N340
6050741.445604203N340
6050751.460897843N340
6280711.075546961N340
6280711.583198774N340
6280712.351989455Y340
6280712.248708736Y340
6280711.729974286N340
6290711.893761762N340
6290712.637689819Y340
6290711.227886705N340
6290722.038222638Y340
6290721.530199698N340
6290722.491081413Y340
6290732.047664195N340
6290731.740362689N340
6290731.910624405N340
6290732.515078675Y340
6290731.627365857N340
6210711.604226053N1965
6210712.264345507Y1965
6210712.062205809Y1965
6210721.555094449N1965
6210721.838219222N1965
6210732.477121255Y1965
6210732.36078269Y1965
6210732.243781916N1965
6210731.117271296N1965
6210741.376576957N1965
6210742.159567193Y1965
6210741.814913181N1965
6290742.142389466Y1965
6290742.354492601Y1965
6290741.829303773N1965
6290741.956648579N1965
6290742.359835482Y1965
6290742.258397804N1965
6290742.438858659N1965
6290752.412628521Y1965
6290752.149219113Y1965
6290752.11058971Y1965
6290752.403977964Y1965
6290751.783188691Y1965
6290752.712902125Y1965
6290761.29666519Y1965
6290761.450249108Y1965
6290762.1532049Y1965
6290761.826074803N1965
6290762.236285277N1965
6290762.168497484Y1965
6290761.614897216N1965
6290771.555094449N1965
6290771.866877814N1965
6290772.520352504Y1965
6290771.58546073N1965
6290771.685741739Y1965




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