BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
iaatoloye
Fluorite | Level 6

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:

 

SAS 10_7_2021 10_49_26 AM.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

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

 

 

 

 

 

View solution in original post

2 REPLIES 2
SteveDenham
Jade | Level 19

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

 

 

 

 

 

iaatoloye
Fluorite | Level 6

Thank you very much, Steve.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

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.

Discussion stats
  • 2 replies
  • 809 views
  • 1 like
  • 2 in conversation