BookmarkSubscribeRSS Feed
Kojema
Fluorite | Level 6

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

1 REPLY 1
djrisks
Barite | Level 11

Hello,

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

 

Many thanks,


Kriss

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 1511 views
  • 0 likes
  • 2 in conversation