View source: R/test_normality.R
test_normality | R Documentation |
Graphical and statistical check if data is Gaussian (three common Normality tests, QQ-plots, histograms, etc).
test_normality
does not show the autocorrelation function (ACF)
estimate for lag 0, since it always equals 1. Thus removing it
does not lose any information, but greatly improves the y-axis scale for
higher order lags (which are usually very small compared to 1).
test_norm
is a shortcut for test_normality
.
test_normality( data, show.volatility = FALSE, plot = TRUE, pch = 1, add.legend = TRUE, seed = sample(1e+06, 1) ) test_norm(...)
data |
a numeric vector of data values. |
show.volatility |
logical; if |
plot |
Should visual checks (histogram, densities, qqplot, ACF) be
plotted? Default |
pch |
a vector of plotting characters or symbols; default |
add.legend |
logical; if |
seed |
optional; if sample size > 5,000, then some normality tests fail to run. In this case it uses a subsample of size 5,000. For reproducibility, the seed can be specified by user. By default it uses a random seed. |
... |
arguments as in |
A list with results of 3 normality tests (each of class htest
)
and the seed used for subsampling:
anderson.darling |
Anderson Darling (if nortest package is available), |
shapiro.francia |
Shapiro-Francia (if nortest package is available), |
shapiro.wilk |
Shapiro-Wilk, |
seed |
seed for subsampling (only used if sample size > 5,000). |
Thode Jr., H.C. (2002): “Testing for Normality”. Marcel Dekker, New York.
shapiro.test
in the stats package;
ad.test
, sf.test
in the
nortest package.
y <- rLambertW(n = 1000, theta = list(beta = c(3, 4), gamma = 0.3), distname = "normal") test_normality(y) x <- rnorm(n = 1000) test_normality(x) # mixture of exponential and normal test_normality(c(rexp(100), rnorm(100, mean = -5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.