cvm.test {dgof} R Documentation

## Discrete Cramer-von Mises Goodness-of-Fit Tests

### Description

Computes the test statistics for doing one-sample Cramer-von Mises goodness-of-fit tests and calculates asymptotic p-values.

### Usage

cvm.test(x, y, type = c("W2", "U2", "A2"),
simulate.p.value=FALSE, B=2000, tol=1e-8)


### Arguments

 x a numerical vector of data values. y an ecdf or step-function (stepfun) for specifying the hypothesized model. type the variant of the Cramer-von Mises test; "W2" is the default and most common method, "U2" is for cyclical data, and "A2" is the Anderson-Darling alternative. For details see references. simulate.p.value a logical indicating whether to compute p-values by Monte Carlo simulation. B an integer specifying the number of replicates used in the Monte Carlo test (for discrete goodness-of-fit tests only). tol used as an upper bound for possible rounding error in values (say, a and b) when needing to check for equality (a==b) (for discrete goodness-of-fit tests only).

### Details

While the Kolmogorov-Smirnov test may be the most popular of the nonparametric goodness-of-fit tests, Cramer-von Mises tests have been shown to be more powerful against a large class of alternatives hypotheses. The original test was developed by Harald Cramer and Richard von Mises (Cramer, 1928; von Mises, 1928) and further adapted by Anderson and Darling (1952), and Watson (1961).

### Value

An object of class htest.

### Author(s)

Taylor B. Arnold and John W. Emerson

Maintainer: Taylor B. Arnold <taylor.arnold@yale.edu>

### References

T. W. Anderson and D. A. Darling (1952). Asymptotic theory of certain "goodness of fit" criteria based on stochastic processes. Annals of Mathematical Statistics, 23:193-212.

V. Choulakian, R. A. Lockhart, and M. A. Stephens (1994). Cramer-von Mises statistics for discrete distributions. The Canadian Journal of Statistics, 22(1): 125-137.

H. Cramer (1928). On the composition of elementary errors. Skand. Akt., 11:141-180.

M. A. Stephens (1974). Edf statistics for goodness of fit and some comparisons. Journal of the American Statistical Association, 69(347): 730-737.

R. E. von Mises (1928). Wahrscheinlichkeit, Statistik und Wahrheit. Julius Springer, Vienna, Austria.

G. S. Watson (1961). Goodness of fit tests on the circle. Biometrika, 48:109-114.

ks.test, ecdf, stepfun

### Examples

require(dgof)

x3 <- sample(1:10, 25, replace=TRUE)

# Using ecdf() to specify a discrete distribution:
ks.test(x3, ecdf(1:10))
cvm.test(x3, ecdf(1:10))

# Using step() to specify the same discrete distribution:
myfun <- stepfun(1:10, cumsum(c(0, rep(0.1, 10))))
ks.test(x3, myfun)
cvm.test(x3, myfun)

# Usage of U2 for cyclical distributions (note U2 unchanged, but W2 not)

set.seed(1)
y <- sample(1:4, 20, replace=TRUE)
cvm.test(y, ecdf(1:4), type='W2')
cvm.test(y, ecdf(1:4), type='U2')
z <- y
cvm.test(z, ecdf(1:4), type='W2')
cvm.test(z, ecdf(1:4), type = 'U2')

# Compare analytic results to simulation results
set.seed(1)
y <- sample(1:3, 10, replace=TRUE)
cvm.test(y, ecdf(1:6), simulate.p.value=FALSE)
cvm.test(y, ecdf(1:6), simulate.p.value=TRUE)



[Package dgof version 1.2 Index]