0
$\begingroup$

I have dive data from ten shark tags. The tags recorded depth every 10 seconds while at liberty and returned a combined total of >900 k depth records. I would like to see if there is a significant difference in the mean dive depth depending on the size of the shark. There are five size categories. Ideally, I would like to apply a 1-way ANOVA, however, ad.test() indicates that the dive data is on a non-normal distribution (the sample size is too large to test via shapiro.test()). I attempted to log(y+1) transform the data (results below) but it still failed ad.test(). enter image description here

I read that a Kruskal-Wallis test is a non-parametric alternative to a 1-way ANOVA, e.g. here which should be followed by post-hoc analysis. However, although sources recommend a Kruskal-Wallis test as a non-parametric alternative, they also say that it tests the median rather than the mean, e.g. here. Am I using an incorrect test? If so, how can I find out if there is a significant difference between the mean dive depths for each shark size category when my dive data is of a non-normal distribution?

For reference, I have included the script below.

Depth<-mydata$Depth
Size<-factor(mydata$Size)

library(lattice)
kruskal.test(Depth,Size)

library(pgirmess) # ad-hoc
kruskalmc(Depth ~ Size, probs = 0.05)
$\endgroup$
1
$\begingroup$

Without seeing numerical and graphical descriptions of dive depths it is difficult to give advice with confidence it is relevant. If you have over 500,000 observations and five categories, then I suppose there must be tens of thousands of dive depth observations per group.

This makes it tempting to suppose that your group means will be roughly normal [see note below], so that an ANOVA would give useful results.

Equal variances? In these circumstances I would worry whether group variances might be grossly unequal. Even with large numbers of replications in each group, this would invalidate a standard ANOVA. Also, an assumption of the original K-W test is that group populations have the 'same shape', which implies equal variances. (Maybe some recent implementations of K-W allow for relaxing this assumption, but you would need to investigate that.)

ANOVA procedure that does not assume equal variances. Thus, I would use the version of a one-way ANOVA implemented in the R procedure oneway.test, which does not assume equal variances. (The approach to correcting for unequal variances is similar to that used in the Welch two-sample t test, but extended to $g > 2$ groups.)

Simulated example with exponential data: If your data were exponential, I suppose you would have found a helpful transformation, but I will use exponential data in an exploratory simulation below: In R, exponential distributions are parameterized by the rate $\lambda = 1/\mu.$

set.seed(2020)
x1 = rexp(10^5, 1/10)
x2 = rexp(10^5, 1/10)
x3 = rexp(10^5, 1/15)
x4 = rexp(10^5, 1/15)
x5 = rexp(10^5, 1/20)
x = c(x1,x2,x3,x4,x5)
g = as.factor(rep(1:5, each=10^5))

Boxplots give an overview of the data. The red X's show the five group means.

boxplot(x ~ g, col="skyblue2", pch=20)
 a = rowMeans(rbind(x1,x2,x2,x4,x5))
 points(1:5, a, pch="X", col="red")

enter image description here

The ANOVA (not assuming equal variances), finds highly significant differences among group means--with a P-value very near $0.$

oneway.test(x ~ g)

     One-way analysis of means 
   (not assuming equal variances)

data:  x and g
F = 7913.5, num df = 4, denom df = 246160, 
  p-value < 2.2e-16

Notice that in a standard ANOVA denom df would be $5(100\,000 - 1)$ which is much greater than $246\,160$ above. This decrease in denominator DF is a 'correction' for grossly different group variances inherited from grossly different population variances $(\sigma_1^2 = \sigma_2^2 = 100,\,$ $\sigma_3^2 = \sigma_4^2 = 225,\,$ $\sigma_5^2 = 400).$

Ad hoc comparisons. We can use Welch 2-sample t tests (also without assuming equal group variances) for ad hoc comparisons. Use Bonferroni or some other method to guard against false discovery.

Knowing how the data were simulated, we would hope to find a significant difference between Groups 2 and 3 $(\mu_2 = 10 \ne \mu_3 = 15),$ but not between Groups 1 and 2 $(\mu_1 = \mu_2 = 10).$ In the first ad hoc comparison we do find a highly significant difference between means of Groups 2 and 3:

t.test(x2, x3)

        Welch Two Sample t-test

data:  x2 and x3
t = -88.042, df = 174060, p-value < 2.2e-16
alternative hypothesis: 
  true difference in means is not equal to 0
...

Only the non-significant P-value $0.775 > 0.05$ is shown for the second ad hoc comparison:

t.test(x1,x2)$p.val
[1] 0.7745113

Note: Means of sample of size $n=100,000$ from exponential distributions with mean $1/\lambda = \mu = 15$ are distributed as $\mathsf{Gamma}(n, n/\lambda)$ [black curve], which is very nearly $\mathsf{Norm}(\mu, \sigma=15/\sqrt{n})$ [red dashes].

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you for a detailed answer, however, it was my understanding that I cannot apply the suggested method as my data is of a non-normal distribution? $\endgroup$
    – Jo Harris
    Apr 20 '20 at 9:58
  • 1
    $\begingroup$ Sorry to be blunt, but the crux of my Answer is that your understanding is not correct. $\endgroup$
    – BruceET
    Apr 20 '20 at 14:36
  • $\begingroup$ Following your comment, I came across the oneway function in the userfriendlyscience package. The following code provided a simple way to apply the suggested ANOVA and post hoc test at the same time oneway(x, y, levene=TRUE, corrections = TRUE, posthoc = 'bonferroni', ...) which though might be helpful for others in future. $\endgroup$
    – Jo Harris
    Apr 20 '20 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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