# Is repeated measures or mixed model ANOVA necessary for this analysis?

I've spent a long time generating and analyzing a dataset and now it comes down to the statistical analysis... and I'm not sure how best to proceed.

In my dataset, I have rats sorted into one of 4 treatment groups. Within each treatment group, data was recorded from each rat at 10 consecutive timepoints. At each timepoint, 23 datapoints (the dependent variable) were collected from each rat, corresponding to 23 discrete depths within the rat cerebral cortex.

So basically, I have three factors to assess in terms of effect on the DV: treatment group, timepoint, and cortical depth.

My intention is to run an ANOVA to determine the significance of effect of each of these factors and/or the interaction effects between factors. I'm not sure what exact paradigm I should use.

I was advised that because I am using timepoint data, that I should use a repeated measures ANOVA. But since treatment group is clearly a fixed variable, does that mean I would need to use a mixed model approach (as I would have both fixed and random variables)?

Furthermore, I am uncertain as to whether to treat depth is a fixed variable or a random variable (like time). Because I am sampling 23 depths from each animal, it seems to me that this is analogous to sampling 10 timepoints from each animal, making depth a random variable. But I'm not at all certain here.

To make matters more complicated, my data was not really collected at discrete timepoints per se. I have averaged the data across designated time intervals to generate discrete values, but in actuality, the data was collected continuously. Taking this into account, perhaps ANCOVA would be appropriate? Or possibly just scrapping the ANOVA idea and going for regression?

To cover all bases, I am currently using Matlab for the data analysis.

Edit: See comment below for more specific experimental details.

• What is the nature of the recorded data? Are the different depths supposed to have 1-1 relations with defined anatomical structures (like layers of cerebral cortex), or do you not know the relation between depth and anatomical structures? What are you trying to learn from the differences among the "timepoints"? How long does it take to cover all 23 depths at a certain "timepoint" and the time that elapses between "timepoints"?
– EdM
Commented Jun 10, 2016 at 0:42
• The data is EEG recorded simultaneously at 23 regularly spaced depths within the cortex. There is no direct correlation with anatomical structures. The recording data is processed via fourier transform to provide 10 spectra representing 10 consecutive 5 minute periods. Power at a particular frequency range is extracted from each spectrum. Each datapoint is the average power over a 5 minute period (timepoint) at a given depth. What we are trying to learn are the effects (i.e. changes in power at a specific frequency) of treatment over time and depth. Commented Jun 10, 2016 at 14:52

A suitable repeated measures (with something like a random timepoint with depth a random effect nested within timepoint) would account for multiple measurements at the same time and at different times being from the same animal. So, yes, depth would needs to also have a random effect associated with it, because the assessments in the same animal at different times and depths are presumably all to some extent correlated.

If you do not have any missing data at any of these combinations, then looking at a set of data with one record from each animal (but never more than one record from the same animal) with ANCOVA should give more or less the same result as an equivalent repeated measures model that has all key interactions (such as pre-treatment value by timepoint by depth, treatment by timepoint by depth etc.), main effects (treatment, timepoint, depth and pre-treatment value), an unstructured covariance matrix (or unstructured combined with unstructured, if you treat the timepoint and depth as nested) and an appropriate calculation of the denominator degrees of freedom (e.g. Kenward-Rogers). If you have some missing assessments, then using a repeated measures model will do an implicit data imputation for you under a missing at random assumption.

Once you are combining multiple depth measurements from the same animal at different times, or different depth at the same time, or different depths across times for the same animal, you would be violating the assumption of independence of residuals and any standard ANOVA/ANCOVA/linear regression would be invalid. The effect would be an inappropriate exaggeration of how much evidence you have, which is avoided by a repeated measures model.

This all works nicely for discrete times and depths. Averaging over some time interval seems a plausible thing to do, if the time intervals are sensibly chosen - e.g. so that not much of a change beyond a bit of random fluctuation should occur during an interval (and if there is important changes e.g. during the course of a day, then you either split the day into sensibly small intervals or take the whole day so that you have a whole cycle). Of course there are also options (even more complicated) that would use the continuously collected data.

• Thank you Bjorn, this is really helpful! If I might ask, because I have both the one fixed variable (treatment group) and the two random variables, does this mean I need to use a mixed-model approach? Or are mixed-model and repeated-measures really distinct models after all? My impression was that repeated-measures is a specific instance of mixed-model, but my understanding is unclear. Commented Jun 10, 2016 at 14:42
• The most typically used repeated measures models are mixed models. What makes them a special subclass is the assumption that the same correlation matrix for repeated observations from different subjects (e.g. time #1 depth #1 & time #2 depth #1 are correlated the same way for all subjects, similarly, time #1 depth #1 & time #2 depth #5). In contrast, if we e.g. model air pollution in districts 1,2,..., of cities A,B,C,..., then it would usually not make sense to assume districts 1 and 2 in city A are correlated in the same way as districts 1 and 2 in city B. Commented Jun 10, 2016 at 15:41
• Given what I say above software that can do mixed effects models typically also covers repeated measures models (e.g. PROC MIXED in SAS, or some lme package in R - e.g. lme4). Commented Jun 10, 2016 at 15:41
• So for my analysis I do not need to create another grouping variable "animal" and nest that variable within the "group" variable. Rather I can simply treat my "time" and "depth" variables as random and nest "time" within "depth" or vice-versa? Commented Jun 10, 2016 at 21:21
• You will need such a variable to tell any software which observations are from the same subject. Think of it as a single random effect for each subject, but it's a vector of length time points × depths. Across subjects this is i.i.d. with e.g. a multivariate normal with a covariance matrix that is to be estimated (either we assume we know nothing about it or introduce some reasonable structure - never be tempted by something excessively simple like AR (1) or compound symmetric though, they are in practice almost certainly too simplistic and such strong assumptions have effects). Commented Jun 11, 2016 at 7:28

This answer should be thought of as an extension to the helpful answer from @Björn, with more detail than could fit into a comment.

As you are measuring field potentials (EEG) at what must be closely spaced depths, the correlations among depths certainly must be taken into account. (Were these, say, action-potential firing rates from different cortical layers, that might not have been such an issue.) Note that the mean values over depth and time aren't at issue; as @Björn notes, the issue is to perform statistical tests that take the correlations into account.

You need, however, to think carefully about what you are trying to learn. From your explanatory comment after @Björn's answer was posted:

What we are trying to learn are the effects (i.e. changes in power at a specific frequency) of treatment over time and depth.

It sounds like you want to track systematic changes over space and time, with a one-dimensional spatial variable. That would make your problem similar to analysis of spatial time-series data. I suppose in the classic agricultural applications of statistics that used to fill textbooks, this would correspond to measuring crop yields (power at your specified frequency) over 10 years (10 time periods) in multiple treatment plots (animals/treatments) on a field that has a gradient of fertility (cortical depth), sampling within each plot along the fertility (depth) gradient. This Cross Validated page and its links may provide some help if you wish to explore such an approach.

Given the decades over which time courses of EEG and more recently fMRI data have been analyzed in brain regions, I suspect that there is precedent in the literature for analysis of your data. You should consider that precedent, as it may already provide an established solution or at least will need to be addressed in your manuscript if you decide on some other analysis approach. Consultation with a local statistical expert might also be wise.

The terminology of "repeated measures" and "mixed model" is partly historical artifact. Back when much emphasis was on ANOVA, "repeated measures" was terminology for multiple measurements from the same individual. The "mixed model" terminology seems to come from the move toward generalized linear models, so that a linear model with both fixed and random predictor variables is "mixed." Don't get hung up on the terminology; do the analysis that best answers the question that you are asking.

• Thank you EdM. I am starting to believe that I am somewhat out of my depth here. I do not have formal statistics training and this entire experimental setup is starting to seem quite complex. I am definitely going to heed your advice to seek out a local statistician and comb through the literature. Commented Jun 10, 2016 at 23:43