# Tests of normality - qq and Shapiro-Wilk

I am new to the world of stats...

My data had a log normal distribution, so transformed by log to get it nearer normal distribution. This is real-world data.

From here I want to establish if my data is normal for parametric tests (ANOVA tests for differences in groups and then Tukey HSD to find out which groups are different).

So i ran a few tests in R:

Median =  1.249979
Mean =  1.278969
Skewness =  0.3918898
Kurtosis = -0.1024776

Shapiro-Wilk normality test
data:  mergedbedanova$logwinterCV W = 0.98709, p-value = 0.01769  The Shapiro-Wilk test suggests that my data is not normal.   Question Is this data normal or 'normal enough' for parametric testing? Or do i need to look at non-parametric tests? • What is your sample size per group? Assumption of ANOVA is not normality of the data but normality of the residuals (see stats.stackexchange.com/questions/6350/…). Further, with large N, Shapiro-Wilk tests tends to detect already quite small deviations from normal distribution. For large N, Central Limit Theorem provides a nice foundation to use ANOVA – LuckyPal Jan 22 '19 at 15:44 • I am running lots of individual ANOVA's based on different groups. One typical set of groups: N=55,65,69,40,24,7 and 5. – Cairan Van Rooyen Jan 22 '19 at 16:17 • The total N=265 observations (participants) – Cairan Van Rooyen Jan 22 '19 at 16:38 • There are two issues here. The main one is that you should not expect the aggregate data to be normal even if the data have normal errors as specified in a linear model. I illustrate this for one simple case in my Answer. [Second, even if there is a slight departure from required normality, results of analysis such as a t test, ANOVA, or linear regression may be useful.] – BruceET Jan 22 '19 at 18:23 • @LuckyPal The CLT alone doesn't get you there because the ANOVA test statistic isn't an externally standardized sample mean. You need more than the CLT because you need to deal with the denominator in the F. With the addition of another theorem, in the limit$n\to\infty\$ it will give a foundation for getting correct type I error rates, but the CLT (etc) doesn't fix the (potentially substantial) issue with low efficiency (low power near H0) – Glen_b Jan 23 '19 at 2:39

You should test the residuals in a one-way ANOVA to see if they are normal. Especially if the levels of the factor are significantly different, there is no reason to expect the aggregate data to be normal.

As an example, suppose the factor has three levels. Then the data for the three levels separately might be as generated below in R, so that we know the conditions for a one-way ANOVA are precisely met:

set.seed(122)
x1 = rnorm(50, 100, 12)
x2 = rnorm(50, 105, 12)
x3 = rnorm(50, 135, 12)
x = c(x1, x2, x3)
shapiro.test(x)

Shapiro-Wilk normality test

data:  x
W = 0.98219, p-value = 0.04922


However, the Shapiro-Wilk test suggests that the aggregate data are not normal. Also, the kernel density estimator plotted through their histogram below shows right skewness somewhat similar to the data you show. The residuals for this model are $$X_{ij} - A_i,$$ for $$i = 1,2,3; j = 1, \dots, 50;$$ where $$A_i = \sum_j X_{ij}.$$

Specifically, for my fake data, the Shapiro-Wilk test shows that the 150 residuals are consistent with normality:

r = c(x1-mean(x1), x2-mean(x2), x3-mean(x3))
shapiro.test(r)

Shapiro-Wilk normality test

data:  r
W = 0.99134, p-value = 0.4933

• Great, thank you. I will test residuals instead of the original data. I will post results soon. Is there any other tests i need to do for ANOVA? I have read about equal variances... – Cairan Van Rooyen Jan 22 '19 at 18:17
• Yes, for a traditional one-way ANOVA, you should check for equal variances. Alternatively, you might use a Welch one-say ANOVA, which does not require equal variances. – BruceET Jan 22 '19 at 18:28

To trust the p-values produced by ANOVA and the post-hoc comparisons, the residuals must be normally distributed. In general, you have two options:

1. Check whether the data within each group is normally distributed (although this is not an assumption of ANOVA, it will usually lead to normally distributed residuals)
2. Check whether the residuals of your ANOVA are normally distributed

Regarding option 1: it is quite difficult to assess normality when one or several of the groups have N < ~30. Hence option 2 might be more promising. Example code to do so in R using the iris dataset is:

fit1 <- aov(Sepal.Length ~ Sepal.Width, data=iris)
qqnorm(fit1$$residuals) hist(fit1$$residuals)


But again, the questions arises: when is normality assumption violated? In many cases, there is no correct answer to this.

However, if all you want to do is comparing those groups and you are not explicitly focussed on fitting a linear model, you cannot do much wrong with choosing non-parametric tests like Kruskal-Wallis and post-hoc adjusted Mann-Whitney tests.

• OK, i have re-run the tests using K-W and found the same significance as ANOVA's, which is great news, as I have spent allot of time analysing the previous ANOVA results and what that means. All i need to do now is test the residuals for normal distribution. – Cairan Van Rooyen Jan 22 '19 at 18:15