2
$\begingroup$

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

I suppose this is normal distribution

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?
$\endgroup$
2
  • 1
    $\begingroup$ Have you visualized the group variability in any way? It may or may not matter depending on the severity. $\endgroup$ Nov 28, 2023 at 11:07
  • $\begingroup$ 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. $\endgroup$
    – scholar101
    Nov 28, 2023 at 11:59

1 Answer 1

1
$\begingroup$
  1. Why do you think you are "going wrong" at all? Sometimes, there isn't homongeneity of variances. What you should do about it depends on various things. You could look at some plots.

  2. Yes, sort of. But violating the different assumptions has different implications and may not always be problematic. There's been a lot of discussion, here and elsewhere, about each assumption.

  3. Yes, however, I would do so graphically rather than by relying on any test.

Since you are using R, you can use the lm function rather than aov and it will show you some very good plots by default. But you can also make your own plots. Which plots to make and how to look at them has also been discussed here a lot.

$\endgroup$
2
  • $\begingroup$ I plotted the PhiPS2 vs elevation using a box-plot, and there were variability in different elevations, which is not surprising, as different elevations have different environmental conditions to show different PhiPS2 (photosynthesis efficiency). Although I have same number of replicates (n=5, each elevation, each sampling time). I don't know how I should account for it. Or is it okay if homogeneity is not necessary? even graphically using plots from plot(aov), I was looking at the 3rd plot there. The redline is not completely parallel to the x-axis, which is needed foe homocaudescity $\endgroup$
    – scholar101
    Nov 28, 2023 at 12:16
  • 1
    $\begingroup$ Two stage analyses distort final inferences and assume the sample size is large enough to correctly guide the choices. Tests of normality don’t have a power of one. Instead use a method such as ordinal regression that makes no distributional or equal variance assumption. $\endgroup$ Nov 28, 2023 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.