ols_test_normality: Test for normality

View source: R/ols-normality-tests.R

ols_test_normalityR Documentation

Test for normality

Description

Test for detecting violation of normality assumption.

Usage

ols_test_normality(y, ...)

## S3 method for class 'lm'
ols_test_normality(y, ...)

Arguments

y

A numeric vector or an object of class lm.

...

Other arguments.

Details

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.

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

References

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.

See Also

Other residual diagnostics: ols_plot_resid_box(), ols_plot_resid_fit(), ols_plot_resid_hist(), ols_plot_resid_qq(), ols_test_correlation()

Examples

model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_test_normality(model)


olsrr documentation built on Nov. 18, 2026, 5:07 p.m.