Code covered by the BSD License  

Highlights from
Shapiro-Wilk and Shapiro-Francia normality tests.

4.88889

4.9 | 10 ratings Rate this file 144 Downloads (last 30 days) File Size: 3.73 KB File ID: #13964

Shapiro-Wilk and Shapiro-Francia normality tests.

by

 

15 Feb 2007 (Updated )

Shapiro-Wilk & Shapiro-Francia parametric hypothesis test of composite normality.

| Watch this File

File Information
Description

Shapiro-Wilk parametric hypothesis test of composite normality, for sample size 3<= n <= 5000. Based on Royston R94 algorithm.
This test also performs the Shapiro-Francia normality test for platykurtic samples.

Acknowledgements

This file inspired Weighted Nonlinear Curve Fit Script With Plotter.

Required Products Statistics Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (16)
20 Sep 2013 Hassan Naseri  
23 Mar 2013 Ahmed Ben Saïda

To answer all questions:
- the kurtosis (line 119) does not modify the power of the test, it's barely used to help choosing between Shapiro-Wilk and Shapiro-Francia method. Moreover, it's better to use the sample kurtosis 'kurtosis(x)'.
- When posing x=norminv((1:9)/10)), x here is not normally distributed, it represents the inverse of the CDF which is not normal by definition. So if you want to test its power you can compute x=normrnd(mu, sigma, n, 1), where you can choose the size of your sample (n) and perform the test.

22 Oct 2012 Willem-Jan de Goeij

Can you explain the following?
x is normally distributed.
If I perform a 2 tailed test, your function rejects the null hypothesis.

x = norminv((1:9)/10);
[h,p,w]=swtest(x,0.05,0)
h =
1
p =
0.0028
w =
0.9925

19 Oct 2012 Sav Deb

Sorry, what is the usefulness of tail option? When to use 1,0 or -1 value?
Thank you for help

13 Mar 2012 Jannick  
14 Jun 2011 rui

i am unable to test the code with my data, and i don't know why.

21 Dec 2010 Ricardo Luis

I tested this code but I have a doubt. In line 119, the kurtosis computation seems to be for a population (kurtosis(x)) and not for a sample (kurtosis(x,0)). So, in line 119 shouldn't it be "if kurtosis(x,0)> 3" (flag=0)?
Thanks.

26 Aug 2010 steven pav

I tested this code for sample sizes as small as 4, and as large as 4096. at all levels tested, the p-values were fairly uniform. Thus it appears this test maintains the nominal rejection rate very well. (the Anderson-Darling test has similarly good performance for small sample sizes.)

23 Feb 2010 Jared Lou

Has anyone Tried to Validate this other than LARS?

10 Feb 2009 Raghav  
04 Dec 2008 Bahriye Basturk Akay

thanks for implementing the code for Shapiro-Wilk and Shapiro-Francia normality tests.

14 Apr 2008 NIZAR OUARTI

good comments,easy to use and reference of the algorythm is present.

23 Mar 2008 Lars Hoffmann

I have the impression, that this implementation is more liberal than it should be according to literature. On 1000 runs at 0.1-level with various sample sizes I calculated an average empirical alpha of 0.11.

28 Feb 2008 Jim Rohlf

Sorry, the file seems ok. My problem was that I had an out-of-date copy of the distchck.m file on my computer.

24 Feb 2008 Jim Rohlf

I just tried it on some test data (n=16) and it crashed because the value of the variable newSWstatistic was imaginary.

06 Mar 2007 Gleb Tcheslavski  
Updates
03 Dec 2007

Change the value in line 136 to 0.26758 instead of 0.026758 (Shapiro-Francia) to correct the significance level. Thanks to Kent Parsons for his remarks.

Contact us