Programming the statistical procedures from SAS

How to code proc mixed with repeated statements for blocking and repeated measures in time?

Reply
Occasional Contributor
Posts: 9

How to code proc mixed with repeated statements for blocking and repeated measures in time?

Hello,

I am performing analyses on water quality data. I want to test whether there are difference in average TP concentrations between 5 sites, and whether these differences depend on the year of sampling.

I have three years of data: 12 samples were taken between March and October in 2014, 11 samples were taken between March and October in 2015, and 9 samples were taken between March and October in 2016.

For every sampling date measurements were taken at all 5 sites. I have attached some “fake” data so you can see how it is structured.

I want to “pair” samples by date to account for variability caused by weather etc. on a given date. I also want to “correct for” temporal autocorrelation- samples taken close together in time are more similar than those taken further apart. I am assuming samples taken in a given year are independent from samples taken in other years. The intervals between measurements are not equal so I am theoretically unable to use variance-covariance structures such as AR(1), toep, arma(1,1), and ante(1).

I have attempted the above in proc mixed with the code at the bottom of the post. To block by day I have included a repeated statement with Date(Year) as the subject. Analyses without accounting for temporal autocorrelation showed an unstructured variance-covariance structure to be the best fit. I am allowing different var-cov matrices for each year with the group=year option. To account for temporal (residual) autocorrelation I added another repeated statement, with Site as the subject, that models the structure of temporal autocorrelation using the sp(exp) option and the variable “Day_nmbr”, which is a continuous variable representing the day as a number between 1 and 365. Note that I also have “Date” as a class variable for purpose of blocking, above. Again, I used the group=year option to allow a different autocorrelation structure in each year. Note-I haven’t explored the best residual autocorrelation model yet, but sp(exp) is a likely fit.

When I run this code with either one of the repeated statements it works, but when I run it with both statements SAS only uses the second statement (I get this message: WARNING: Only the last REPEATED statement is used). I am presuming (or perhaps hoping!) that I have just coded something incorrectly. Perhaps there is a way to combine the repeated statements? Can anyone help me think of a way to code that will allow me to do what I have described?

Thanks for any help!!

 

Code:

 

Proc mixed data=sites;

class Date Year Site;

model TP = Site Year Site*Year / solution ddfm=kenwardroger outp= pred_data;

Repeated / subject= Date(Year) type=un group=year r rcorr;

Repeated / subject= Site type=sp(exp)(Day_nmbr)group=year r rcorr;

run;

 

I am using SAS 9.3

Super Contributor
Posts: 252

Re: How to code proc mixed with repeated statements for blocking and repeated measures in time?

Hello,

Maybe you can just use two proc mixed statements and have one repeated statement in each proc mixed statement?

 

Many thanks,


Kriss

Ask a Question
Discussion stats
  • 1 reply
  • 89 views
  • 0 likes
  • 2 in conversation