20
$\begingroup$

I have some data which looks from plotting a graph of residuals vs time almost normal but I want to be sure. How can I test for normality of error residuals?

$\endgroup$
2

3 Answers 3

31
$\begingroup$
  1. No test will tell you your residuals are normally distributed. In fact, you can reliably bet that they are not.

  2. Hypothesis tests are not generally a good idea as checks on your assumptions. The effect of non-normality on your inference is not generally a function of sample size*, but the result of a significance test is. A small deviation from normality will be obvious at a large sample size even though the answer to the question of actual interest ('to what extent did this impact my inference?') may be 'hardly at all'. Correspondingly, a large deviation from normality at a small sample size may not approach significance.

    * (added in edit) -- actually that's much too weak a statement. The impact of non-normality actually decreases with sample size pretty much any time the CLT and Slutsky's theorem is going to hold, while the ability to reject normality (and presumably avoid normal-theory procedures) increases with sample size ... so just when you're most able to identify non-normality tends to be when it doesn't matter$^\dagger$ anyway... and the test is no help when it actually matters, in small samples.

    $\dagger$ well, at least as far as significance level goes. Power can still be an issue though if we are considering large samples as here, that may be less of an issue as well.

  3. What comes closer to measuring effect size is some diagnostic (either a display or a statistic) that measures degree of non-normality in some way. A Q-Q plot is an obvious display, and a Q-Q plot from the same population at one sample size and at a different sample size are at least both noisy estimates of the same curve - showing roughly the same 'non-normality'; it should at least approximately be monotonically related to the desired answer to the question of interest.

If you must use a test, Shapiro-Wilk is probably about as good as anything else (the Chen-Shapiro test is typically a bit better on alternatives of common interest, but harder to find implementations of) -- but it's answering a question you already know the answer to; every time you fail to reject, it's giving an answer you can be sure is wrong.

$\endgroup$
9
  • 4
    $\begingroup$ +1 Glen_b because you make several good points. However I would not be so negative about the use of goodness of fit tests. When the sample size is small or moderate the test will not have sufficient power to detect slight departures from the normal distribution. Very large differences might result in very small p-values (e.g. 0.0001 or lower). These may be more formal indications than the visual observation of a qq plot but still very useful. One can also look at estimates of skewness and kurtosis. It is in very large samples that the goodness of fit tests are problematic. $\endgroup$ Sep 13, 2012 at 10:31
  • 4
    $\begingroup$ In those cases small departures will be detected. As long as the analyst recognizes that in practice the population distribution will not be exactly normal and rejecting the null hpyothesis is just telling him that his distribution is slightly non-normal, he won't go astray. The investigator should then judge for himself whether the assumption of normality is a concern or not given the slight departure that the test detects. Shapiro-Wilk is actually one of the more powerful tests against the hypothesis of normality. $\endgroup$ Sep 13, 2012 at 10:36
  • $\begingroup$ +1, I especially like point #2; along those lines, it's worth noting that even if skew or kurtosis is fairly bad, w/ really large N, the Central Limit Theorem will cover you, so that's the time you least need normality. $\endgroup$ Sep 13, 2012 at 20:09
  • 3
    $\begingroup$ @gung there are some circumstances when a good approximation to normality will matter. For example, when constructing prediction intervals using normal assumptions. But I still would rely more on a diagnostic (one which shows how non-normal it is) than a test $\endgroup$
    – Glen_b
    Sep 14, 2012 at 3:10
  • $\begingroup$ Your point about prediction intervals is a good one. $\endgroup$ Sep 14, 2012 at 4:00
8
$\begingroup$

The Shapiro-Wilk test is one possibility.

Shapiro-Wilk test

This test is implemented in almost all statistical software packages. The null hypothesis is the residuals are normally distributed, thus a small p-value indicates you should reject the null and conclude the residuals are not normally distributed.

Note that if your sample size is large you will almost always reject, so visualization of the residuals is more important.

$\endgroup$
1
  • $\begingroup$ It is "Wilk" not "Wilks". $\endgroup$ Sep 13, 2012 at 10:37
1
$\begingroup$

From wikipedia:

Tests of univariate normality include D'Agostino's K-squared test, the Jarque–Bera test, the Anderson–Darling test, the Cramér–von Mises criterion, the Lilliefors test for normality (itself an adaptation of the Kolmogorov–Smirnov test), the Shapiro–Wilk test, the Pearson's chi-squared test, and the Shapiro–Francia test. A 2011 paper from The Journal of Statistical Modeling and Analytics concludes that Shapiro-Wilk has the best power for a given significance, followed closely by Anderson-Darling when comparing the Shapiro-Wilk, Kolmogorov-Smirnov, Lilliefors, and Anderson-Darling tests.

$\endgroup$
5
  • 1
    $\begingroup$ -1: You might want to include a link to the Wikipedia page, remove the footnote ("[1]") and use the blockquote function. $\endgroup$ Sep 13, 2012 at 8:24
  • 1
    $\begingroup$ The caveat that Glen_b gives is imprtant to keep in mind whenever any of these goodness of fit tests are used. I think the result you quoye about Shapiro-Wilk is not as general as you make it out to be. I don't believe there is a globally most powerful test for normality. $\endgroup$ Sep 13, 2012 at 10:41
  • 2
    $\begingroup$ @MichaelChernick I believe that SnowsPenultimateNormalityTest (implemented in the TeachingDemos package for R (cran.r-project.org/web/packages/TeachingDemos/TeachingDemos.pdf)) could fit the description of globally most powerful test (for $n \ge 1$). But I also believe that the documentation for the test/function is more useful than the test/function itself. $\endgroup$
    – Greg Snow
    Sep 13, 2012 at 16:56
  • $\begingroup$ @GregSnow I don't have the time to take thorough look through your package and I may not be adept enough with R to follow everything. Are you saying that there is a globally most powerful test for normality or are you saying that you provide examples to show when various tests are most powerful and therefore that a global one does not exist. I have my doubts that one exists and I don't think Shapiro-Wilk would be it. If you are claiming that one exists, I would like to see a mathematical proof or a reference to one. $\endgroup$ Sep 13, 2012 at 17:32
  • 1
    $\begingroup$ @MichaelChernick, my claim is that my test will have as much power or more (be as or more likely to reject the null hypothesis of the data coming from an exact normal) as any other test of normality. The R code is not hard to follow, the core code for computing the p-value is "tmp.p <- if( any(is.rational(x))) { 0", the proof of its power should be obvious (I only claimed that it is powerful and the documentation may be useful, not that the test itself is useful, google for "Cochrane's aphorism"). $\endgroup$
    – Greg Snow
    Sep 13, 2012 at 18:10

Your Answer

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

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