« Sandy's seminar | Main | Wired, NASDAQ, and the Christmas Question »

## November 10, 2004

### Variance Components

I was fitting a three-way ANOVA model (with two drugs, E2 and NAL, either present or absent and TIME having 4 levels) and found that the assumption of constant variance in each cell was questionable. Bartlett's test (performed with "means factor / hovtest=Bartlett" where factor is a oneway ANOVA factor, in this case created to indicate each of 16 unique combinations of E2, NAL, and TIME) wasn't quite significant, but there was a definite fan shape in the residuals showing a sharp reduction in the variance as time increased.

It was an easy conclusion to fit a model with the same fixed effects structure but with four different variance parameters, one for each level of the time factor. However, finding out how to make SAS fit that model is a separate issue entirely.

I was pretty sure that PROC MIXED had the answer, but wasn't sure exactly what REPEATED or RANDOM statement would be required. It turns out that the secret line is "REPEATED / GROUP=TIME" does the trick. Notice that there's no factor that's actually repeated, the group option being the critical piece.

Structurally this is the same as doing a stratified analysis where each time's data is analyzed separately if there's an interaction of TIME with the E2 and NAL effects. The reason for trying so hard to get it all in one model is to be able to make all pairwise comparisons (including across times) using Tukey's method.

I have an additional question about this analysis. While there's no overall R-squared to report from the mixed model, it still seems to make sense that each time's R-squared could be calculated (since the four variance parameters have the same estimates as a stratified analysis) and appropriately reported to give an idea of how good the model fit is. Any arguments or alternatives to this approach?

Posted by roge0285 at November 10, 2004 1:23 PM