pval_shapiro {DemographicTable} | R Documentation |
Obtain p-value from Shapiro-Wilk normality test, taking into consideration of several exceptions.
pval_shapiro(x, CLT = FALSE)
x |
double vector |
CLT |
logical scalar, whether to allow the use of Central Limit Theorem (default |
pval_shapiro provides a pseudo p-value for the several exceptions of shapiro.test function, serving as a criteria of whether robust statistics/tests need to be used
length(x) < 3L
return 0
, robust methods needed
length(x) > 5e3L
return 1
, no robust method needed (robust methods could be too slow)
CLT & length(x) > 30L
return 1
, no robust method needed because of the use of Central Limit Theorem
all x
values identical return 0
, robust methods needed.
Otherwise use the p-value from shapiro.test
pval_shapiro returns a double scalar.
pval_shapiro(rnorm(5))
sapply(with(airquality, split(Ozone, f = Month)), FUN = pval_shapiro)