Normality Test in Excel

5
Normality Test tutorial 1© Spider Financial Corp, 2012 Facts and Myths about Normality Test In time series and econometric analysis and modeling, we often encounter the normality test as part of the residuals diagnosis to validate a model’s assumption(s). Does the Normality test 1 tell us whether standardized residuals follow a Gaussian distribution? Not exactly. So, what exactly does this test do? Why do we have several different methods for testing normality? Note: For illustration, we simulated 5 series of random numbers using the Analysis Pack in Excel. Each series has a different underlying distribution: Normal, Uniform, Binomial, Poisson, Student’s t and F distribution. Background Let’s assume we have a data set of a univariate ( {} t x ), and we wish to determine whether the data set is wellmodeled by a Gaussian distribution. 1 : ~ (.) : (.) o H X N H X N Where o H = null hypothesis ( X is normally distributed) 1 H = alternative hypothesis ( X distribution deviates from Gaussian) (.) N = Gaussian or normal distribution In essence, the normality test is a regular test of a hypothesis that can have two possible outcomes: (1) rejection of the null hypothesis of normality ( o H ), or (2) failure to reject the null hypothesis. 1 You can use the normal probability plots (i.e. QQ plots) as an informal means of assessing the nonnormality of a set of data. However, you may need considerable practice before you can judge them with any degree of confidence.

description

This mini tutorial demonstrates the steps to perform a statistical test for Normality assumption in Excel using NumXL function - NormalityTest.For the example spreadsheet and tutorial video, visit us at:http://bitly.com/I9SThf

Transcript of Normality Test in Excel

Page 1: Normality Test in Excel

 

Normality Test tutorial  ‐1‐  © Spider Financial Corp, 2012  

FactsandMythsaboutNormalityTestIn time series and econometric analysis and modeling, we often encounter the normality test as part of 

the residuals diagnosis to validate a model’s assumption(s).  

 

Does the Normality test1 tell us whether standardized residuals follow a Gaussian distribution? Not 

exactly. 

So, what exactly does this test do? Why do we have several different methods for testing normality?  

Note: For illustration, we simulated 5 series of random numbers using the Analysis Pack in Excel. Each 

series has a different underlying distribution: Normal, Uniform, Binomial, Poisson, Student’s t and F 

distribution. 

BackgroundLet’s assume we have a data set of a univariate ({ }tx ), and we wish to determine whether the data set 

is well‐modeled by a Gaussian distribution. 

 1

: ~ (.)

: (.)oH X N

H X N 

Where 

oH = null hypothesis ( X is normally distributed) 

1H = alternative hypothesis ( X distribution deviates from Gaussian) 

(.)N = Gaussian or normal distribution 

In essence, the normality test is a regular test of a hypothesis that can have two possible outcomes: (1) 

rejection of the null hypothesis of normality ( oH ), or (2) failure to reject the null hypothesis. 

                                                            1 You can use the normal probability plots (i.e. Q‐Q plots) as an informal means of assessing the non‐normality of a set of data. However, you may need considerable practice before you can judge them with any degree of confidence. 

Page 2: Normality Test in Excel

 

Normality Test tutorial  ‐2‐  © Spider Financial Corp, 2012  

In practice, when we can’t reject the null hypothesis of normality, it means that the test fails to find 

deviance from a normal distribution for this sample. Therefore, it is possible the data is normally 

distributed. 

The problem we typically face is that when the sample size is small, even large departures from 

normality are not detected; conversely, when your sample size is large, even the smallest deviations 

from normality will lead to a rejected null. 

NormalityTestsHow do we test for normality?  In principle, we compare the empirical (sample) distribution with a 

theoretical normal distribution.  The measure of deviance can be defined based on distribution 

moments, a Q‐Q plot, or the difference summary between two distribution functions.  

Let’s examine the following normality tests: 

‐ Jarque‐Bera test 

‐ Shapiro‐Wilk test 

‐ Anderson – Darling test 

Jarque‐BeraThe Jarque‐Bera test is a goodness‐of‐fit measure of departure from normality based on the sample 

kurtosis and skew. In other words, JB determines whether the data have the skew and kurtosis matching 

a normal distribution. 

The test is named after Carlos M. Jarque and Anil K. Bera. The test statistic for JB is defined as: 

 2

2 22~

6 4

n KJB S

 

Where 

S = the sample skew 

K = the sample excess kurtosis 

n = the number of non‐missing values in the sample 

JB = the test statistic;  JB has an asymptotic chi‐square distribution 

Notes:  For small samples, the chi‐squared approximation is overly sensitive, often rejecting the null 

hypothesis (i.e. normality) when it is in fact true. 

Page 3: Normality Test in Excel

 

Normality Test tutorial  ‐3‐  © Spider Financial Corp, 2012  

 

In the table above, we compute the P‐value of the normality test (Using the Normality Test function in 

NumXL).  Note that the JB test failed to detect a departure from normality for symmetric distributions 

(e.g. Uniform and Students) using a small sample size ( 50n ). 

Shapiro‐WilkBased on the informal approach to judging 

normality, one rather obvious way to judge 

the near linearity of any Q‐Q plot (see Figure 

1) is to compute its "correlation coefficient."  

 

When this is done for normal probability (Q‐

Q) plots, a formal test can be obtained that is 

essentially equivalent to the powerful 

Shapiro‐Wilk test W and its approximation 

W. 

  

 

2

( )1

2

( )1

N

i ii

N

ii

a x

Wx X

 

 

Figure 1: Q‐Q Plot Example

Page 4: Normality Test in Excel

 

Normality Test tutorial  ‐4‐  © Spider Financial Corp, 2012  

Where 

( )iX = the ith order (smallest number) in the sample 

ia  = a constant given by 

1

1 2 1 1( , ,..., )

( )

T

n T

m Va a a

m V V m

 

m = the expected values of the order statistics of independent and identical distributed random 

variables sampled from Gaussian distribution 

V = the covariance matrix of { }m order statistics 

 

In the table above, the SW P‐values are significantly better for small sample sizes ( 50n ) in detecting 

departure from normality, but exhibit similar issues with symmetric distribution (e.g. Uniform, Student’s 

t). 

Anderson‐DarlingThe Anderson‐Darling tests for normality are based on the empirical distribution function (EDF). The test 

statistics is based on the squared difference between normal and empirical: 

  2

1

1(2 1) ln (2 1 2 ) ln(1 )

N

i iiA n i U n i U

n  

 

Page 5: Normality Test in Excel

 

Normality Test tutorial  ‐5‐  © Spider Financial Corp, 2012  

In sum, we construct an empirical distribution 

using the sorted sample data, compute the 

theoretical (Gaussian) cumulative distribution ( iU ) 

at each point ( ( )ix ) and, finally, calculate the test 

statistic. 

 

 

 

And, in the case where the variance and mean of the normal distribution are both unknown, the test 

statistic is expressed as follows: 

  *2 22

4 251A A

n n

 

Note: The AD Test is currently planned for the next NumXL release; we won’t show results here, as you 

can’t yet reproduce them. 

ConclusionThese three tests use very different approaches to test for normality: (1) JB uses the moments‐based 

comparison, (2) SW examines the correlation in the Q‐Q plot and (3) AD tests the difference between 

empirical and theoretical distributions.  

In a way, the tests complement each other, but some are more useful in certain situations than others. 

For example, JB works poorly for small sample sizes (n<50) or very large sample sizes (n>5000). 

The SW method works better for small sample sizes (n>3 but less than 5000). 

In terms of power, Stephensi found AD statistics (  2A ) to be one of the best EDF statistics for detecting 

departure from normality, even when used with small samples ( 25n ). Nevertheless, the AD test has 

the same problem with a large sample size, where slight imperfections lead to a rejection of a null 

hypothesis. 

 

 

                                                            i Stephens, M. A. (1974). "EDF Statistics for Goodness of Fit and Some Comparisons". Journal of the American Statistical Association 69: 730–737 

Figure 2: Empirical Distribution Function (EDF vs. Normal)