The goal of checknormality is to provide implementations of popular normality tests that return the test statistics and p-values. As of 2020/11/30, the package contains an implementation of the Shapiro-Wilk Test of Normality.
For n > 50, the J. P. Royston approach for the Shapiro-Wilk test as described here must be used.
For 3 \<= n \<= 50, there are three “approaches”: the original approach for the Shapiro-Wilk test as described here, a modified approach that is compatible with the Royston approach as described in the last paragraph here, and the Royston approach for n > 20.
stats::qnorm(p)
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("chrsshn/checknormality")
set1 <- rexp (30, .8)
checknormality::sw_test (set1, "original")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set1
#> W = 0.83101, p-value = 0.001
checknormality::sw_test (set1, "modified")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set1
#> W = 0.83101, p-value = 0.001
checknormality::sw_test (set1, "royston")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set1
#> W = 0.82613, p-value = 2e-04
stats::shapiro.test (set1)
#>
#> Shapiro-Wilk normality test
#>
#> data: set1
#> W = 0.82643, p-value = 0.0002067
plot(density (set1))
Note: you can also get the W test statistic using the functions checknormality::R_get_W () and checknormality::C_get_W()
set2 <- rnorm (40, 20, 5)
checknormality::sw_test (set2, "original")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set2
#> W = 0.96354, p-value = 0.355
checknormality::sw_test (set2, "modified")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set2
#> W = 0.96354, p-value = 0.355
checknormality::sw_test (set2, "royston")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set2
#> W = 0.9722, p-value = 0.4215
stats::shapiro.test (set2)
#>
#> Shapiro-Wilk normality test
#>
#> data: set2
#> W = 0.96989, p-value = 0.3569
plot(density (set2))
note: the original and modified approaches are only valid for n \< 50 points
set3 <- rpois(4000, .787)
checknormality::sw_test (set3, "royston")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set3
#> W = 0.78822, p-value < 2.2e-16
stats::shapiro.test (set3)
#>
#> Shapiro-Wilk normality test
#>
#> data: set3
#> W = 0.78829, p-value < 2.2e-16
plot(density (set3))
note: the original and modified approaches are only valid for n \< 50 points
set4 <- rnorm(4000)
checknormality::sw_test (set4, "royston")
#>
#> Shapiro-Wilk Test of Normality
#>
#> data: set4
#> W = 0.99926, p-value = 0.1011
stats::shapiro.test (set4)
#>
#> Shapiro-Wilk normality test
#>
#> data: set4
#> W = 0.99934, p-value = 0.1608
plot(density (set4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.