logo

Shapiro-Wilk Test 📂Statistical Test

Shapiro-Wilk Test

Hypothesis Testing

Given quantitative data $\left\{ x_{i} \right\}_{i = 1}^{n}$.

  • $H_{0}$: Data $\left\{ x_{i} \right\}_{i = 1}^{n}$ follows a normal distribution.
  • $H_{1}$: Data $\left\{ x_{i} \right\}_{i = 1}^{n}$ does not follow a normal distribution.

Description

The Shapiro-Wilk test is a hypothesis test used to assess the normality of data, usually to demonstrate that normality is present. It’s one of the rare occasions where having the null hypothesis accepted matches ’the analyst’s intention’, hence understanding the hypothesis precisely is crucial.

Code

Practice

In R, the shapiro.test() function allows for an easy conduct of the Shapiro-Wilk test. Generate the following two random samples and actually perform the Shapiro-Wilk test.

histogramofN.png histogramofgeo.png

N represents data from a normal distribution, and geo represents data from a geometric distribution.

20190303\_223206.png

The test results exactly as expected.

Full Code

Below is an example of the R code.

set.seed(150421)
 
N<-rnorm(100)
win.graph(4,4); hist(N)
shapiro.test(N)
 
geo<-rgeom(100,0.5)
win.graph(4,4); hist(geo)
shapiro.test(geo)

See Also