I am working on a project with collaborators who use R- I am trying to recode an one of their analyses in SAS. It is a mixed effects model using the attached data (df1.csv). In our experimental design, individual chambers (numbered 1- 27) are sited within three levels of topography. An individual chamber only appears in one topography. Each chamber repeatedly measures CO2 from sequential time points (Days). Rainfall is thought to be an important driving variable for CO2.
The R code for the model is
lme.mod <- lme(log(co2)~(Days+Topography+Rainfall)^2,random=~Topography|Chamber, correlation=corARMA(p=1,q=0),na.action=na.exclude, control = lmeControl(msMaxIter = 200, msMaxEval = 500,sing.tol=1e-20),data=df1) anova(lme.mod) Anova(lme.mod) # initial model with 2 way interactions between all factors/variables and allowing topography-specific variance across chambers (chamber as random effect); for temporal autocorrelation, start with (1,0) corARMA model # one ANOVA is F test, one is Type 2 Chi-sq; worth doing both to confirm sig. effect
which produces the output for fixed effects:
numDF denDF F-value p-value (Intercept) 1 4826 313.06357 <.0001 Days 1 4826 0.66294 0.4156 Topography 2 24 282.28233 <.0001 Rainfall 1 4826 29.08699 <.0001 Days:Topography 2 4826 0.39228 0.6755 Days:Rainfall 1 4826 1.67336 0.1959 Topography:Rainfall 2 4826 8.91292 0.0001
My interpretation of the code is that the model has random factor fixed effects of chamber nested within topography, with an autoregressive structure (the measurements are repeated on each chamber at each time point). I want to code the equivalent in SAS; I create the log of the CO2 variable in the data step before I run the model. My code is here
DATA DF; INFILE FLUX FIRSTOBS= 2 DLM=',' MISSOVER; INPUT OBS DAYS TOPOGRAPHY $ CO2 CHAMBER RAINFALL JUNK; LOGCO2= LOG(CO2); RUN;
PROC SORT NODUPKEY; BY CHAMBER DAYS; RUN;
PROC MIXED DATA= DF MAXFUNC= 500 MAXITER= 200; WHERE LOGCO2 NE .; CLASS CHAMBER DAYS TOPOGRAPHY ; MODEL LOGCO2= DAYS TOPOGRAPHY RAINFALL DAYS * TOPOGRAPHY DAYS * RAINFALL TOPOGRAPHY * RAINFALL / SOLUTION RESIDUAL DDFM= BW ; RANDOM CHAMBER(TOPOGRAPHY) ; REPEATED DAYS / SUBJECT= CHAMBER*DAYS TYPE= AR(1) R; RUN;
but it produces output very different from the R script:
SAS Output
Type 3 Tests of Fixed Effects
Effect
Num DF
Den DF
F Value
Pr > F
DAYS
12
4489
2.95
0.0004
TOPOGRAPHY
2
4489
218.94
<.0001
RAINFALL
0
.
.
.
DAYS*TOPOGRAPHY
356
4489
1.54
<.0001
RAINFALL*DAYS
0
.
.
.
RAINFALL*TOPOGRAPHY
0
.
.
.
Can anyone help me understand i) why the output is so different. I understand that thee are various ways to calculate the denominator df, but why are the numerator df so different?? ii) why am I not getting a result for the rainfall variable in my Type 3 tests?
Thank you in advance
... View more