Hi,
I am trying to run a two-way ANOVA repeated measure using PROC GLIMMIX. My first factor is soil type with two levels and the second factor is treatment with four levels and the repeated measure is days. I tried the code below but I am not sure if this is correct. I am using GLIMMIX instead of MIXED because I found it easier to using LSMEANS for mean comparisons.
Proc Glimmix data=idinc.labstud
plots=studentpanel;
class treatment soiltype rep day ;
lNitrate_Ammon =log(Nitrate_Ammon);
model lNitrate_Ammon = treatment|soiltype|day;
random day / subject=treatment(day) soiltype(day) type=ar(1) residual v vcorr;
run;
I get this error:
The error is that your RANDOM statement has terms in it that are not recognized.
Here is your code:
random day / subject=treatment(day) soiltype(day) type=ar(1) residual v vcorr;
Day within soiltype is a problem for the subject= option to recognize. Instead try this:
random day / subject=day(rep) type=ar(1) residual v vcorr;
Here I assume that there are multiple reps of each of the 8 soil by treatment combinations, and that these are uniquely identified. If reps are nested within the design by treatment, this becomes:
random day / subject=day(rep*treatment) type=ar(1) residual v vcorr
If rep is nested within soiltype, substitute in for treatment, and if nested within both, but with nonunique rep identifiers, try this:
random day / subject=day(rep*treatment*soiltype) type=ar(1) residual v vcorr
Finally, depending on how many reps you have, and how they are identified, you might consider adding another RANDOM statement, so that the block of random statements looks like:
random intercept/subject=rep*treatment*soiltype;
random day / subject=day(rep*treatment*soiltype) type=ar(1) residual v vcorr
SteveDenham
The error is that your RANDOM statement has terms in it that are not recognized.
Here is your code:
random day / subject=treatment(day) soiltype(day) type=ar(1) residual v vcorr;
Day within soiltype is a problem for the subject= option to recognize. Instead try this:
random day / subject=day(rep) type=ar(1) residual v vcorr;
Here I assume that there are multiple reps of each of the 8 soil by treatment combinations, and that these are uniquely identified. If reps are nested within the design by treatment, this becomes:
random day / subject=day(rep*treatment) type=ar(1) residual v vcorr
If rep is nested within soiltype, substitute in for treatment, and if nested within both, but with nonunique rep identifiers, try this:
random day / subject=day(rep*treatment*soiltype) type=ar(1) residual v vcorr
Finally, depending on how many reps you have, and how they are identified, you might consider adding another RANDOM statement, so that the block of random statements looks like:
random intercept/subject=rep*treatment*soiltype;
random day / subject=day(rep*treatment*soiltype) type=ar(1) residual v vcorr
SteveDenham
Thank you very much, Steve.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.