BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
gmorris
Calcite | Level 5

Hello,

 

I am trying to run a repeated measures analysis in proc mixed and am not sure how to handle a repeated aspect of the experiment that generated this data. The experiment investigated the effects of weather on rodent foraging in foraging patches (the response is the amount of grain left after a night a foraging). We measured this in 12 different sites for 19 different sessions. Within each session, we measured grain for 3 nights.  Here is an example of the data:

 

site   session   night   grain_left

1         1               1           1.66

1         1               2          1.50

1         1               3          1.57

1         2              1           1.52

1         2              2          1.48

1         2              3          1.41

2         1              1           1.10

2         1              2          0.98

2         1              3          0.83

2         2             1           0.66

2         2             2          0.59

2         2             3          0.55

       

I expect the results for each site to be closely correlated for the 3 nights within each session but also expect some (lesser) correlation from session to session.

I have found examples of how to handle data with nesting (e.g., providers nested in hospitals) but I have not seen examples of how to handle nesting of time within time (nesting night within session).  Based on what I have read, I think this may be an appropriate way to code this:

 

proc mixed data=grain_left method=REML;
class site night session;
model grain_left = weather_variables /solution residual ddfm=satterthwaite;
repeated night(session) /subject=site type=ar(1);
run;

 

This code runs, but I am not certain this is the best way to code this.  Could anyone share any thoughts on whether this is appropriate, and if not, a better way to handle this?  Or recommend resources that discuss this kind of experimental design?

 

Thanks very much!

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Look at the documentation for the REPEATED statement in PROC MIXED. You should see that there are 3 types of Kronecker product covariance structures to handle doubly repeated measures. In this case, I would suggest type=UN@CS or perhaps UN@AR(1). I would align "session" with the unstructured part and "night" with the autoregressive part, as in:

 

proc mixed data=grain_left method=REML;
class site night session;
model grain_left = weather_variables night session /solution residual ddfm=satterthwaite;
repeated session night /subject=site type=un@ar(1) r;
run;

This adds night and session as fixed effects, such that the error structure refers to the residuals from the MODEL statement. Behavior of the algorithm with Kronecker types can be spotty, but so long as you have enough data, it should give what you are looking for. It worked on the example data once I removed weather_variables from the MODEL statement.

 

SteveDenham

 

View solution in original post

3 REPLIES 3
SteveDenham
Jade | Level 19

Look at the documentation for the REPEATED statement in PROC MIXED. You should see that there are 3 types of Kronecker product covariance structures to handle doubly repeated measures. In this case, I would suggest type=UN@CS or perhaps UN@AR(1). I would align "session" with the unstructured part and "night" with the autoregressive part, as in:

 

proc mixed data=grain_left method=REML;
class site night session;
model grain_left = weather_variables night session /solution residual ddfm=satterthwaite;
repeated session night /subject=site type=un@ar(1) r;
run;

This adds night and session as fixed effects, such that the error structure refers to the residuals from the MODEL statement. Behavior of the algorithm with Kronecker types can be spotty, but so long as you have enough data, it should give what you are looking for. It worked on the example data once I removed weather_variables from the MODEL statement.

 

SteveDenham

 

gmorris
Calcite | Level 5

Thank you very much!  I had tried something similar before but ran into problems - possibly because I had not included session and night as fixed effects. So far this is working with the full dataset. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 485 views
  • 5 likes
  • 3 in conversation