View source: R/ols-normality-tests.R
| ols_test_normality | R Documentation |
Test for detecting violation of normality assumption.
ols_test_normality(y, ...)
## S3 method for class 'lm'
ols_test_normality(y, ...)
y |
A numeric vector or an object of class |
... |
Other arguments. |
The tests differ in the sample sizes they support. shapiro.test()
requires between 3 and 5000 observations, and nortest::ad.test() and
nortest::cvm.test() require at least 8. ks.test() does not
document a sample-size limit of its own, but a minimum of 3 observations is
required here so that the test is meaningful. Tests whose sample-size
requirement is not met are skipped: their statistic and p-value are returned
as NA and a single warning lists the skipped tests and the reason. If
the sample is too small for every test, the function stops with an error.
The Cramér–von Mises test is nortest::cvm.test(), the test of
composite normality, which compares the data with a normal distribution
whose mean and standard deviation are estimated from the data. It is
deterministic. For very small p-values the test reports 7.37e-10
with a warning instead of a more precise value.
ols_test_normality returns an object of class "ols_test_normality".
An object of class "ols_test_normality" is a list containing the
following components:
kolmogorv |
kolmogorv smirnov statistic |
shapiro |
shapiro wilk statistic |
cramer |
cramer von mises statistic |
anderson |
anderson darling statistic |
Stephens, M. A. (1986). Tests based on EDF statistics. In R. B. D'Agostino and M. A. Stephens (Eds.), Goodness-of-Fit Techniques (pp. 97–193). New York: Marcel Dekker.
Thode, H. C. (2002). Testing for Normality. New York: Marcel Dekker.
Other residual diagnostics:
ols_plot_resid_box(),
ols_plot_resid_fit(),
ols_plot_resid_hist(),
ols_plot_resid_qq(),
ols_test_correlation()
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_test_normality(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.