knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) set.seed(80)
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") checknormality::sw_test (set1, "modified") checknormality::sw_test (set1, "royston") stats::shapiro.test (set1) plot(density (set1))
Note: you can also get the W test statistic using the functions checknormality::R_get_W () and checknormality::C_get_W()
``` {r echo = T, eval = T} set2 <- rnorm (40, 20, 5) checknormality::sw_test (set2, "original") checknormality::sw_test (set2, "modified") checknormality::sw_test (set2, "royston") stats::shapiro.test (set2) plot(density (set2))
### Example 3: Testing a large sample from a Poisson distribution using the Royston approach note: the original and modified approaches are only valid for n < 50 points ``` {r echo = T, eval = T} set3 <- rpois(4000, .787) checknormality::sw_test (set3, "royston") stats::shapiro.test (set3) plot(density (set3))
note: the original and modified approaches are only valid for n < 50 points ``` {r echo = T, eval = T} set4 <- rnorm(4000) checknormality::sw_test (set4, "royston") stats::shapiro.test (set4) plot(density (set4))
```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.