# What should I check for normality: raw data or residuals?

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.

• Are you doing this using software (and if so which software) or are you trying to do the calculations by hand? – Chris Simokat Jun 18 '11 at 1:27
• @Chris Simokat: I'm trying to do this with R and Statistica... – stan Jun 18 '11 at 1:38
• 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. – gung Oct 6 '12 at 1:30
• @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 ;) ? – stan Nov 4 '12 at 14:40
• 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. – gung Nov 4 '12 at 14:45

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.

• 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. – whuber Jun 18 '11 at 21:20
• @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). – Greg Snow Jun 18 '11 at 21:56
• 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? – stan Jun 20 '11 at 22:36
• (+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. – Nick Cox Oct 4 '18 at 10:33

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 .After a reasonable model captured the day-of-the-week, holiday/events effects , level shifts/time trends we get

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

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.

• 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. – stan Jun 18 '11 at 11:00
• 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. – Glen Jun 18 '11 at 14:45
• @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... – stan Jun 19 '11 at 23:27