# Repeated ANOVA unbalanced data

I did experiment on one group of rats, the group was tested during 8 days, this is the first stage. The same group was also tested again but this time the test phase was 7 days. I tried to do my analysis using ANOVA repeated measures but I had a problem with the days.. I want to know the difference in the 2 tests but the days are not the same number. I don't know how to handle it. If there is any way to do the analysis using repeated measures ANOVA.

I tried to use repeated measure anova within subjects effect. My first factor will be test with 2 levels (test 1 & 2),second factor is day with the level of ?? Here is the problem! if I write 8 there will be extra day in test 2 and the analysis cant carry!!

• If there is any way to do the analysis without dropping the day 8? I heard about the r software? what do you think? Do I need another software if I would like to carry the analysis without dropping the day 8? – user36083 Dec 12 '13 at 7:35

Drop Day 8. Then you have a standard $n \times 2 \times 7$ repeated measures design that lets you test both the Stage and Day main effects and the Stage $\times$ Day interaction.

I would recommend looking into mixed-effects models (also called random-effects models, multilevel models). They don't require balanced data--i.e., they handle missing data on the dependent variable--so you wouldn't have to drop your Day 8.

You can do them in R, e.g. with the package lme4 or nlme. SPSS, SAS, Stata, Mplus can all run those models too. (Note that you need one observation per line, so you'll end up with several lines for each rat.) For your particular situation, it looks like you would have observations nested under rats, with two level-1 predictors (test, which has 2 levels, and day, which has 8 levels). In R, using lme4 and assuming you have a data frame df with variables dv (your dependent variable at each observation), test (which is your grouping factor), day (which is the testing day), and rat (which is the rat identifier), it could go like this:

require(lme4)
lmer(dv ~ test + day + (1|rat), data=df)


If you treat day as a categorical predictor (as is done in repeated-measures ANOVA), then you cannot include the interaction between test and day, because day #8 occurs for only one level of test. However, if you treat day as a continuous variable (as is typically done in multilevel modeling), then including the interaction would be possible, and would be done like this:

lmer(dv ~ test + day + test:day + (1|rat), data=df)