25
$\begingroup$

I've learnt that I must test for normality not on the raw data but their residuals. Should I calculate residuals and then do the Shapiro–Wilk's W test?

Are residuals calculated as: $X_i - \text{mean}$ ?

Please see this previous question for my data and the design.

$\endgroup$
  • $\begingroup$ Are you doing this using software (and if so which software) or are you trying to do the calculations by hand? $\endgroup$ – Chris Simokat Jun 18 '11 at 1:27
  • $\begingroup$ @Chris Simokat: I'm trying to do this with R and Statistica... $\endgroup$ – stan Jun 18 '11 at 1:38
  • 3
    $\begingroup$ This question may be of interest: what-if-residuals-are-normally-distributed-but-y-is-not; it also covers the issue of whether normality is required of the raw data or the residuals. $\endgroup$ – gung Oct 6 '12 at 1:30
  • $\begingroup$ @gung: thanks for the comment, I've already liked it :). I was told that I have to calculate residuals before a normality test. Now I'm trying to understand how to make SAS to do it for me with different (long, wide) data set orientations. Any idea ;) ? $\endgroup$ – stan Nov 4 '12 at 14:40
  • 1
    $\begingroup$ Sorry, I'm not savvy enough w/ SAS to know how to make it do this automatically in different situations. However, when you run a regression, you should be able to save the residuals to an output dataset, & a qq-plot can then be made. $\endgroup$ – gung Nov 4 '12 at 14:45
35
$\begingroup$

Why must you test for normality?

The standard assumption in linear regression is that the theoretical residuals are independent and normally distributed. The observed residuals are an estimate of the theoretical residuals, but are not independent (there are transforms on the residuals that remove some of the dependence, but still give only an approximation of the true residuals). So a test on the observed residuals does not guarantee that the theoretical residuals match.

If the theoretical residuals are not exactly normally distributed, but the sample size is large enough then the Central Limit Theorem says that the usual inference (tests and confidence intervals, but not necessarily prediction intervals) based on the assumption of normality will still be approximately correct.

Also note that the tests of normality are rule out tests, they can tell you that the data is unlikely to have come from a normal distribution. But if the test is not significant that does not mean that the data came from a normal distribution, it could also mean that you just don't have enough power to see the difference. Larger sample sizes give more power to detect the non-normality, but larger samples and the CLT mean that the non-normality is least important. So for small sample sizes the assumption of normality is important but the tests are meaningless, for large sample sizes the tests may be more accurate, but the question of exact normality becomes meaningless.

So combining all the above, what is more important than a test of exact normality is an understanding of the science behind the data to see if the population is close enough to normal. Graphs like qqplots can be good diagnostics, but understanding of the science is needed as well. If there is concern that there is too much skewness or potential for outliers, then non-parametric methods are available that do not require the normality assumption.

$\endgroup$
  • 5
    $\begingroup$ To answer the question on the first line: Approximate normality is crucial for applying F-tests in ANOVA and for creating confidence limits around variances. (+1) for the good ideas. $\endgroup$ – whuber Jun 18 '11 at 21:20
  • 4
    $\begingroup$ @whuber, yes approximate normality is important, but the tests test exact normality, not approximate. And for large sample sizes that approximate does not have to be very close (where the tests are most likely to reject). A good plot and knowledge of the science that produced the data are much more usefull than a formal test of normality if you are justifying using F-tests (or other normal based inference). $\endgroup$ – Greg Snow Jun 18 '11 at 21:56
  • $\begingroup$ Greg, OK I do distribution fitting and see my data are from, let say, Beta or Gamma distribution and what should I do then? ANOVA that assumes Gaussian law? $\endgroup$ – stan Jun 20 '11 at 22:36
  • 2
    $\begingroup$ (+1) This went well except at the end. You don't have to choose between (a) regression based on a normality assumption and (b) nonparametric procedures. Transformations before regression and/or generalized linear models are just two major alternatives. I recognise that you're not trying here to summarize all about statistical modelling, but the last part could be amplified slightly. $\endgroup$ – Nick Cox Oct 4 '18 at 10:33
7
$\begingroup$

The Gaussian Asuumptions refer to the residuals from the model. There are no assumptions necessary about the original data. As a case in point the distribution of daily beer sales enter image description here .After a reasonable model captured the day-of-the-week, holiday/events effects , level shifts/time trends we get enter image description here

$\endgroup$
  • $\begingroup$ thanks for your reply. You want to say that we can transform our data to Gaussian distribution...? $\endgroup$ – stan Jun 20 '11 at 6:13
  • 3
    $\begingroup$ Stan, the role of modelling is to do exactly that so inference can be made and hypothesis tested. $\endgroup$ – IrishStat Jun 20 '11 at 20:50
6
$\begingroup$

First you can "eyeball it" using a QQ-plot to get a general sense here is how to generate one in R.

According to the R manual you can feed your data vector directly into the shapiro.test() function.

If you would like to calculate the residuals yourself yes each residual is calculated that way over your set of observations. You can see more about it here.

$\endgroup$
  • $\begingroup$ So, as far as I understood methods for Normality actually check normality of residuals of our raw data. They do that automatically and we shouldn't calculate residuals and subject them to the test. And in everyday speech we usually switch to "my data are normally distributed" assuming residuals of my data are "normal". Please, correct me. $\endgroup$ – stan Jun 18 '11 at 11:00
  • 6
    $\begingroup$ I disagree with your last point. People who say my data are normally distributed are usually not referring to the residuals. I think people say that because they think every statistical procedure requires all data to be normal. $\endgroup$ – Glen Jun 18 '11 at 14:45
  • $\begingroup$ @Glen frankly speaking I (falsely) think the same so far... I can't understand (this is my trouble) if I have gamma or beta or whatever distributed data should I do statistics for them as the same as they are normally distributed despite their true/natural distribution? And the fact of distribution is only for indication? I've known only Gaussian distribution before this site... $\endgroup$ – stan Jun 19 '11 at 23:27

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.