Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

cvm.test

Cramer-Von Mises Test of Goodness-of-Fit


Description

Performs the Cramer-von Mises test of goodness-of-fit to a specified continuous univariate probability distribution.

Usage

cvm.test(x, null = "punif", ..., estimated=FALSE, nullname)

Arguments

x

Numeric vector of data values.

null

A function, or a character string giving the name of a function, to compute the cumulative distribution function for the null distribution.

...

Additional arguments for the cumulative distribution function.

estimated

Logical value indicating whether the parameters of the distribution were estimated using the data x (composite null hypothesis), or were fixed in advance (simple null hypothesis, the default).

nullname

Optional character string describing the null distribution. The default is "uniform distribution".

Details

This command performs the Cramer-von Mises test of goodness-of-fit to the distribution specified by the argument null. It is assumed that the values in x are independent and identically distributed random values, with some cumulative distribution function F. The null hypothesis is that F is the function specified by the argument null, while the alternative hypothesis is that F is some other function.

By default, the test assumes that all the parameters of the null distribution are known in advance (a simple null hypothesis). This test does not account for the effect of estimating the parameters.

If the parameters of the distribution were estimated (that is, if they were calculated from the same data x), then this should be indicated by setting the argument estimated=TRUE. The test will then use the method of Braun (1980) to adjust for the effect of parameter estimation.

Note that Braun's method involves randomly dividing the data into two equally-sized subsets, so the p-value is not exactly the same if the test is repeated. This technique is expected to work well when the number of observations in x is large.

Value

An object of class "htest" representing the result of the hypothesis test.

Author(s)

Adrian Baddeley.

References

Braun, H. (1980) A simple method for testing goodness-of-fit in the presence of nuisance parameters. Journal of the Royal Statistical Society 42, 53–63.

Csorgo, S. and Faraway, J.J. (1996) The exact and asymptotic distributions of Cramer-von Mises statistics. Journal of the Royal Statistical Society, Series B 58, 221–234.

See Also

pCvM for the null distribution of the test statistic.

Examples

x <- rnorm(10, mean=2, sd=1)
cvm.test(x, "pnorm", mean=2, sd=1)
cvm.test(x, "pnorm", mean=mean(x), sd=sd(x), estimated=TRUE)

goftest

Classical Goodness-of-Fit Tests for Univariate Distributions

v1.2-2
GPL (>= 2)
Authors
Julian Faraway [aut], George Marsaglia [aut], John Marsaglia [aut], Adrian Baddeley [aut, cre]
Initial release
2019-11-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.