# Two-way ANOVA Unbalanced Samples

I am currently working on a project where I need to evaluate the influence of physiographic region (5 levels) and age (3 levels) on a continuous variable called ASI. I originally planned on a 2-way ANOVA using the following coding:

results=lm(ASI~PHYS_CODE*AGE,data=combinedData)


The output: After running the analysis, I tested the assumptions:

Normality of Residuals: Homogeneity of Variance:

leveneTest(ASI ~ as.factor(PHYS_CODE)*as.factor(AGE),data=combinedData) This makes sense since I have unequal sample sizes (or unbalanced data). What would be the best way to resolve this issue in a 2-way ANOVA?

• With your p values, I wouldn't worry about non-normality. With your sample sizes, I wouldn't bother with significance testing since it would be obvious that the null hypothesis can be rejected if the mean differences are not essentially 0. – David Lane Mar 22 '17 at 21:21

David Lane's comment is very thoughtful, and you should consider that. As well as affecting your p-values, your huge sample size will cause Levene's test to always fail, as samples that size will never have the same variance. So you basically have three options

1. Decide whether the variance inequality is sufficiently large to severely impact your two-way ANOVA.

3. Use an alternative test.

Option 1 is the easier one to resolve. It would be helpful if we could see some graphs that show the variance of each group. Simply by eyeballing it, it is the variance difference quite extreme? Or fairly similar? All sorts of rules of thumb are thrown around, but many people seem to power ahead when the largest variance is no more than three times the smallest variance. So try looking at your data this way, rather than relying on the statistical test.

Option 2 may work. There are a variety of transformations that may stabilise your variance (Box-cox, square root, log, etc.). Whether this stabilisation comes at the cost of your normality is another question.

Also of note is that transformations typically make the interpretation of your data much more difficult. You would need to carefully think about the transformation that you're applying, and how it is going to affect your interpretation.

Finally, option 3. There are several procedures for dealing with heteroescasdicity. You might want to look at robust regression, using rlm in the MASS package. There might also be non-parametric options such as adonis in the vegan package (although I'm not sure if that will deal with unequal variance).

Finally, you could use a process that explicitly models the variances, rather than making assumptions about them. I would recommend looking at gls in the nlme package as well as this answer.

Explicitly modelling unequal variances in a linear model to get better conf/pred intervals?

Hope some of this will help solve your problem.