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!
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
Calling @SteveDenham @lvm @StatDave
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
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 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.