# Anova model assumptions. How to go by?

I have a data frame that contains a continuous response variable measured on different species, at different elevation and month of sampling as explanatory variables. I want to analyze how the response variable varies with elevation and time. For that, I am thinking of using a two-way ANOVA test, as I also want to look at the additive affect of both of the explanatory variables.

In order to do that, I believe, I must fulfill the model assumptions: normality and homogeneity of the residuals. I tried checking for it using the Shapiro-Wilk test and visualization to see if there was a normal distribution. I also used Levene's test for homogeneity.

# Main Effects
aov.PhiPS2.sqrt<-aov(sqrt(PhiPS2) ~ elevation, data=ecophy_df)
shapiro.test(aov.PhiPS2.sqrt$residuals) # Interaction aov.PhiPS2.sqrt<-aov(sqrt(PhiPS2) ~ elevation*month, data=ecophy_df) plot(aov.PhiPS2.sqrt) shapiro.test(aov.PhiPS2.sqrt$residuals)


The Shapiro-Wilk normality test results are shown below:

data:  aov.PhiPS2.log\$residuals
W = 0.99546, p-value = 0.5039


BUT, when running leveneTest(PhiPS2_sq~elevation, data =ecophy_df), the homogeneity test fails, completely, as shown below:

Levene's Test for Homogeneity of Variance (center = median)
Df F value    Pr(>F)
group   9  6.6826 1.002e-08 ***
300
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> leveneTest(PhiPS2_sq~elevation*month, data =ecophy_df)
Levene's Test for Homogeneity of Variance (center = median)
Df F value    Pr(>F)
group  39  2.4877 1.077e-05 ***
270
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


So my questions are:

1. Where am I going wrong?
2. Is it necessary to fulfill both assumptions?
3. Should each model that I will use be tested for normality and homogeneity?
• Have you visualized the group variability in any way? It may or may not matter depending on the severity. Commented Nov 28, 2023 at 11:07
• Yes. There is variability in PhiPS2 in different elevations, I checked using a box-plot of PhiPS2 vs elevation. I don't know if it is causing the non-homogeneity. Commented Nov 28, 2023 at 11:59