
Cramer-Von Mises Test for Assessing Deviations From Normality
Source:R/cramerVonMisesTest.R
cramerVonMisesTest.RdA goodness-of-fit test based on the integrated squared discrepancies between the empirical and theoretical distribution functions. Similar to the Anderson-Darling test, but without increased weighting of the distribution tails.
Value
A list with class "htest" containing the following
components:
statisticthe value of the Cramer-von Mises statistic.
p.valuethe p-value of the test.
methoda character string indicating the test performed.
data.namea character string giving the name of the data.
Details
Performs the Cramer-von Mises test for the composite hypothesis of normality, see e.g. Thode (2002, Sec. 5.1.3).
The Cramer-von Mises test is an EDF omnibus test for the composite hypothesis of normality. The test statistic is $$W = \frac{1}{12 n} + \sum_{i=1}^{n} \left(p_{(i)} - \frac{2i - 1}{2n}\right)^2,$$ where \(p_{(i)} = \Phi([x_{(i)} - \bar{x}]/s)\). Here, \(\Phi\) is the cumulative distribution function of the standard normal distribution, and \(\bar{x}\) and \(s\) are mean and standard deviation of the data values. The p-value is computed from the modified statistic \(Z = W (1 + 0.5/n)\) according to Table 4.9 in Stephens (1986).
Missing values are silently removed.
Note
Based on code by Juergen Gross previously published in the nortest package, adapted to conform to package standards.
References
Stephens, M.A. (1986) Tests based on EDF statistics. In: D'Agostino, R.B. and Stephens, M.A., eds.: Goodness-of-Fit Techniques. New York: Marcel Dekker.
Thode Jr., H.C. (2002) Testing for Normality. New York: Marcel Dekker.
See also
shapiro.test() for performing the Shapiro-Wilk test
for normality, andersonDarlingTest(),
pharos::plotQQ() for producing extended normal quantile-quantile
plots
Other test.normality:
andersonDarlingTest(),
jarqueBeraTest(),
lillieTest(),
pearsonTest(),
shapiroFranciaTest()
Examples
set.seed(1)
cramerVonMisesTest(rnorm(100, mean = 5, sd = 3))
#>
#> Cramer-von Mises normality test
#>
#> data: rnorm(100, mean = 5, sd = 3)
#> W = 0.026031, p-value = 0.8945
#>
cramerVonMisesTest(runif(100, min = 2, max = 4))
#>
#> Cramer-von Mises normality test
#>
#> data: runif(100, min = 2, max = 4)
#> W = 0.27466, p-value = 0.0006342
#>