Shapiro

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Shapiro-Wilk Test

Introduction:

 Shapiro and Wilk develop a goodness of fit test for normality that may be used instead of the
Lilliefors test.
 Some empirical studies indicate that this test has good power in many situations when
compare with Lilliefors and Chi-square test.
 The data consist of random sample 𝑋1 , 𝑋2 … 𝑋𝑛 of size 𝑛 associated with some unknown
distribution function 𝐹(𝑥).
 Assumption: The sample is a random sample.
Objective: The Shapiro–Wilk test can be used to decide whether or not a sample fits a normal
distribution, and it is commonly used for small samples (𝑛 < 50).
Parametric Counterpart: The parametric counterpart of the Shapiro-Wilk test is the Anderson-
Darling test. Both tests are used to assess the normality assumption of a dataset, but they differ in their
approaches.

Procedure:
Step 1
𝐻𝑜 : 𝐹(𝑥) is a normal distribution function with unspecified mean and variance.
𝐻1 : 𝐹(𝑥) is non-normal.
Step 2
Level of significance: 𝛼 = 0.05 (unless otherwise stated)
Step 3
Test Statistic: First compute the denominator 𝐷 of the test statistics 𝐷 = ∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2 where 𝑥̅ is the
sample mean. Then order the sample from smallest to largest 𝑥1 ≤ ⋯ ≤ 𝑥𝑛 . From the Shapiro-Wilks
𝑛
table for the observed sample size 𝑛, obtain the coefficients 𝑎1 , 𝑎2 , … , 𝑎𝑚 . If 𝑛 is even, then 𝑚 = ,
2
(𝑛−1)
while if 𝑛 is odd then 𝑚 = 2
. The test statistics 𝑊 is given as:
1
𝑊= [∑𝑚
𝑖=1 𝑎𝑖 (𝑥𝑛+1−𝑖 − 𝑥𝑖 )]2
𝐷

Step 4
Calculations:
Step 5
Critical Region: Reject 𝐻𝑜 if 𝑊 < 𝑊𝛼 (from Shapiro-Wilks table)
Step 6
Conclusion:
Example 1
A random sample of 12 people is taken from a large population.65,61,63,86,70,55,74,35,72,68,45,58.
Is this data normally distributed?
Solution:
Step 1
𝐻𝑜 : The data is normally distributed.
𝐻1 : The data is not normally distributed.
Step 2
Level of significance: 𝛼 = 0.05
Step 3
1
Test Statistic: 𝑊 = [∑𝑚 2 𝑛
𝑖=1 𝑎𝑖 (𝑥𝑛+1−𝑖 − 𝑥𝑖 )] , where 𝐷 = ∑𝑖=1(𝑥𝑖 − 𝑥̅ )
2
𝐷

Step 4
Calculations: For calculation of [∑𝑚
𝑖=1 𝑎𝑖 (𝑥𝑛+1−𝑖 − 𝑥𝑖 )]
2
𝑛 12
𝑛 =12, 𝑚 = 2 = 2
=6

𝑖 Age Sorted Data 𝑎𝑖 (𝑥𝑛+1−𝑖 − 𝑥𝑖 ) 𝑎𝑖 (𝑥𝑛+1−𝑖 − 𝑥𝑖 )


1 65 35 𝑎1 =0.5475 𝑥12 − 𝑥1 = 86 − 35 = 51 27.9225
2 61 45 𝑎2 =0.3325 𝑥11 − 𝑥2 = 74 − 45 = 29 9.6425
3 63 55 𝑎3 =0.2347 𝑥10 − 𝑥3 = 86 − 35 = 17 3.9899
4 86 58 𝑎4 =0.1586 𝑥9 − 𝑥4 = 72 − 55 = 12 1.9032
5 70 61 𝑎5 =0.0922 𝑥8 − 𝑥5 = 70 − 58 = 7 0.6454
6 55 63 𝑎6 =0.0303 𝑥7 − 𝑥6 = 65 − 63 = 2 0.0606
7 74 65 Total=44.1641
8 35 68
9 72 70
10 68 72
11 45 74
12 58 86

For calculation of 𝐷 = ∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2

(𝑥𝑖 − 𝑥̅ )2 (𝑥𝑖 − 𝑥̅ )2
765.446 28.4441
312.112 53.7773
58.7783 87.1105
21.7781 128.444
2.77789 544.443
0.11109 Total= 2008.67
5.44429
(44.1641)2
𝑊= = 0.9170
2008.67
Step 5
Critical Region: Reject 𝐻𝑜 if 𝑊 < 𝑊𝛼 (from Shapiro-Wilks table)
𝑊 < 𝑊0.05
𝑊 < 0.859
Step 6
Conclusion: Can not reject 𝐻𝑜
Large Sample Size: Shapiro and Francia (1972) suggest an approximate test for 𝑛 greater tha 50 that
is similar to Shapiro-Wilk test.
Example 2
A random sample of 60 people is taken from a large population 47, 32, 55, 28, 63, 41, 38, 49, 52, 45,
36, 58, 29, 44, 51, 33, 42, 57, 39, 48, 31, 53, 46, 35, 50, 37, 60, 30, 43, 54, 56, 40, 61, 34, 59, 27, 62,
64, 25, 70, 26, 68, 67, 69, 66, 72, 73, 74, 71, 65, 23, 75, 22, 24, 21, 76, 20, 19, 18, 77, 17, 78.Is this
data normally distributed?
Solution:
Step 1
𝐻𝑜 : The data is normally distributed.
𝐻1 : The data is not normally distributed.
Step 2
Level of significance: 𝛼 = 0.05
Step 3
ln(1−𝑊 ′ )−𝜇
Test Statistic: 𝑍 = 𝜎

where
∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )(𝑚𝑖 − 𝑚
̅)
𝑊′ =
2
√[∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2 ][∑𝑛𝑖=1(𝑚𝑖 − 𝑚
̅) ]

𝜇 = 0.0038915(ln 𝑛)3 − 0.083751(ln 𝑛)2 − 0.31082 ln 𝑛 − 1.5861


2 −0.082676 ln 𝑛−0.4803
𝜎 = 𝑒 0.0030302(ln 𝑛)
Step 4
Calculations:

𝑖 Age Sorted Data (𝑥𝑖 ) 𝑚𝑖 𝑖 Age Sorted Data (𝑥𝑖 ) 𝑚𝑖


1 47 17 -2.31 31 56 48 0.02
2 32 18 -1.93 32 40 49 0.06
3 55 19 -1.71 33 61 50 0.1
4 28 20 -1.55 34 34 51 0.15
5 63 21 -1.43 35 59 52 0.19
6 41 22 -1.32 36 27 53 0.23
7 38 23 -1.23 37 62 54 0.27
8 49 24 -1.14 38 70 55 0.32
9 52 26 -1.07 39 26 56 0.36
10 45 27 -1 40 68 58 0.41
11 36 28 -0.93 41 67 58 0.45
12 58 29 -0.87 42 69 59 0.5
13 29 30 -0.81 43 66 60 0.55
14 44 31 -0.75 44 72 61 0.59
15 51 32 -0.7 45 73 62 0.65
16 33 33 -0.65 46 74 63 0.7
17 42 34 -0.59 47 71 65 0.75
18 58 35 -0.55 48 65 66 0.81
19 39 36 -0.5 49 23 67 0.87
20 48 37 -0.45 50 75 68 0.93
21 31 38 -0.41 51 22 69 1
22 53 39 -0.36 52 24 70 1.07
23 46 40 -0.32 53 21 71 1.14
24 35 41 -0.27 54 76 72 1.23
25 50 42 -0.23 55 20 73 1.32
26 37 43 -0.19 56 19 74 1.43
27 60 44 -0.15 57 18 75 1.55
28 30 45 -0.1 58 77 76 1.71
29 43 46 -0.06 59 17 77 1.93
30 54 47 -0.02 60 78 78 2.31
𝑖 − 3/8
𝑚𝑖 = Φ−1 ( )
𝑛 + 1/4
1−3/8
i.e., 𝑚1 = Φ−1 (60+1/4) ⇒ 𝑚1 = Φ−1 (0.0104) ⇒ 𝑚1 = −2.31 (From Standard Normal
Distribution table).
For Calculation of
∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )(𝑚𝑖 − 𝑚
̅)
𝑊′ =
2
√[∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2 ][∑𝑛𝑖=1(𝑚𝑖 − 𝑚
̅) ]

Numerator:

(𝑥𝑖 − 𝑥̅ ) (𝑚𝑖 − 𝑚̅) (𝑥𝑖 − 𝑥̅ )(𝑚𝑖 − 𝑚


̅) (𝑥𝑖 − 𝑥̅ ) (𝑚𝑖 − 𝑚̅) (𝑥𝑖 − 𝑥̅ )(𝑚𝑖 − 𝑚
̅)
-30.6167 -2.3126 70.8029 0.3833 0.0208 0.00797
-29.6167 -1.9273 57.0803 1.3833 0.06245 0.08638
-28.6167 -1.7107 48.9545 2.3833 0.1042 0.24833
-27.6167 -1.5534 42.8993 3.3833 0.14613 0.49441
-26.6167 -1.4272 37.9869 4.3833 0.18832 0.82548
-25.6167 -1.3203 33.8227 5.3833 0.23086 1.24276
-24.6167 -1.2267 30.1985 6.3833 0.27381 1.7478
-23.6167 -1.1428 26.9897 7.3833 0.31727 2.34251
-21.6167 -1.0663 23.049 8.3833 0.36134 3.02925
-20.6167 -0.9955 20.5235 10.3833 0.40613 4.21697
-19.6167 -0.9294 18.2312 10.3833 0.45175 4.69061
-18.6167 -0.8671 16.1424 11.3833 0.49832 5.67255
-17.6167 -0.808 14.2344 12.3833 0.54601 6.76135
-16.6167 -0.7516 12.4894 13.3833 0.59496 7.96259
-15.6167 -0.6975 10.893 14.3833 0.64539 9.28289
-14.6167 -0.6454 9.43352 15.3833 0.69752 10.7302
-13.6167 -0.595 8.10145 17.3833 0.75162 13.0656
-12.6167 -0.546 6.88879 18.3833 0.80801 14.8538
-11.6167 -0.4983 5.78885 19.3833 0.86709 16.8071
-10.6167 -0.4517 4.79605 20.3833 0.92937 18.9436
-9.6167 -0.4061 3.90563 21.3833 0.99548 21.2867
-8.6167 -0.3613 3.11359 22.3833 1.06626 23.8664
-7.6167 -0.3173 2.41656 23.3833 1.14282 26.723
-6.6167 -0.2738 1.8117 24.3833 1.22675 29.9122
-5.6167 -0.2309 1.29664 25.3833 1.32034 33.5146
-4.6167 -0.1883 0.86944 26.3833 1.42718 37.6538
-3.6167 -0.1461 0.52851 27.3833 1.55338 42.5367
-2.6167 -0.1042 0.27265 28.3833 1.7107 48.5552
-1.6167 -0.0624 0.10096 29.3833 1.9273 56.6305
-0.6167 -0.0208 0.01283 30.3833 2.31256 70.2632

∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )(𝑚𝑖 − 𝑚
̅ )= 1027.5893
Denominator:

(𝑥𝑖 − 𝑥̅ )2 (𝑚𝑖 − 𝑚̅ )2 (𝑥𝑖 − 𝑥̅ )2 (𝑚𝑖 − 𝑚̅ )2


937.3823 5.34793 0.146919 0.00043
877.1489 3.7145 1.913519 0.0039
818.9155 2.92649 5.680119 0.01086
762.6821 2.41299 11.44672 0.02135
708.4487 2.03685 19.21332 0.03547
656.2153 1.74329 28.97992 0.05329
605.9819 1.50491 40.74652 0.07497
557.7485 1.30604 54.51312 0.10066
467.2817 1.13691 70.27972 0.13057
425.0483 0.99098 107.8129 0.16494
384.8149 0.86373 107.8129 0.20407
346.5815 0.75185 129.5795 0.24832
310.3481 0.65287 153.3461 0.29812
276.1147 0.56493 179.1127 0.35398
243.8813 0.48653 206.8793 0.41653
213.6479 0.41653 236.6459 0.48653
185.4145 0.35398 302.1791 0.56493
159.1811 0.29812 337.9457 0.65287
134.9477 0.24832 375.7123 0.75185
112.7143 0.20407 415.4789 0.86373
92.48092 0.16494 457.2455 0.99098
74.24752 0.13057 501.0121 1.13691
58.01412 0.10066 546.7787 1.30604
43.78072 0.07497 594.5453 1.50491
31.54732 0.05329 644.3119 1.74329
21.31392 0.03547 696.0785 2.03685
13.08052 0.02135 749.8451 2.41299
6.847119 0.01086 805.6117 2.92649
2.613719 0.0039 863.3783 3.7145
0.380319 0.00043 923.1449 5.34793

2
∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2 =19096.18333, ∑𝑛𝑖=1(𝑚𝑖 − 𝑚
̅ ) =57.1166
2
√[∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2 ][ ∑𝑛𝑖=1(𝑚𝑖 − 𝑚
̅ ) ] = √(19096.18333)(57.1166) = 1044.3702

1027.5893
𝑊′ = = 0.9839
1044.3702
ln(1−𝑊 ′ )−𝜇
Now, 𝑍 = 𝜎
𝜇 = 0.0038915(ln 𝑛)3 − 0.083751(ln 𝑛)2 − 0.31082 ln 𝑛 − 1.5861
𝜇 = 0.0038915(ln(60))3 − 0.083751(ln(60))2 − 0.31082 ln(60) − 1.5861
𝜇 =-3.9956
2
𝜎 = 𝑒 0.0030302(ln 𝑛) −0.082676 ln 𝑛−0.4803
2
𝜎 = 𝑒 0.0030302(ln(60)) −0.082676 ln(60)−0.4803
𝜎 =0.46394
ln(1 − 0.9839) − (−3.9956)
𝑍= = −0.29146
0.46394
P-value= 0.614 ((From Standard Normal Distribution table)
Step 5
Critical Region: Reject 𝐻𝑜 if 𝑃_𝑣𝑎𝑙𝑢𝑒 < 𝛼
Step 6
Conclusion: Cannot reject 𝐻𝑜

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy