cvm.test.lmomco: Cramér-von Mises Test for Goodness-of-Fit

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

The Cramér–von Mises test for goodness-of-fit is implemented for the order statistics x_{1:n} ≤ x_{i:n} ≤ x_{n:n} of a sample of size n. Define the test statistic (Csörgő and Faraway, 1996) as

ω^2 = \frac{1}{12n} + ∑_{i=1}^n \biggl[\frac{2i-1}{2n} - F_θ(x_i)\biggr]\mbox{,}

where F_θ(x) is the cumulative distribution function (continuous) for some distribution having parameters θ. If the value for ω^2 is larger than some critical value, reject the null hypothesis. The null hypothesis is that F is the function specified by θ, while the alternative hypothesis is that F is some other function.

Usage

1
cvm.test.lmomco(x, para1, ...)

Arguments

x

A vector of data values.

para1

The parameters of the distribution.

...

Additional arguments to pass to par2cdf.

Details

The above definition for ω^2 as the Cramér–von Mises test statistic is consistent with the notation in Csörgő and Faraway (1996) as well as that in package goftest. Depending on how the null distribution is defined by other authors and attendant notation, the Cramér–von Mises statistic can be branded as T = nω^2. The null distribution herein requires just ω^2 and the sample size is delivered separately into the cumulative distribution function:

1
  goftest::pCvM(omega.sq, n=n, lower.tail=FALSE)

Value

An R list is returned.

null.dist

The null distribution, which is an echoing of the para argument, which recall for lmomco that is contains the distribution abbreviation.

text

The string “Cramer-von Mises test of goodness-of-fit”.

statistic

The ω^2 as defined above (see Note).

p.value

The p-value computed from the pCvM() function from the goftest package for the null distribution of the test statistic.

source

An attribute identifying the computational source of the L-moments:
“cvm.test.lmomco”.

Note

An example of coverage probabilities demonstrating the differences in what the p-values mean on whether the parent is known or the "parent" is coming from the sample. The p-values are quite different and inference has subtle differences. In ensemble, comparing the test statistic amongst distribution choices might be more informative than a focus on p-values being below a critical alpha.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  parent <- vec2par(c(20,120), type="gam"); nsim <- 10000
  pp <- nn <- ee <- rep(NA,nsim)
  for(i in 1:nsim) {
    x <- rlmomco(56, parent); lmr <- lmoms(x)
    pp[i] <- cvm.test.lmomco(x,          parent          )$p.value
    nn[i] <- cvm.test.lmomco(x, lmom2par(lmr, type="nor"))$p.value
    ee[i] <- cvm.test.lmomco(x, lmom2par(lmr, type="exp"))$p.value
  }
  message("GAMMA PARENT KNOWN     'rejection rate'=", sum(pp < 0.05)/nsim)
  message("ESTIMATED NORMAL       'rejection rate'=", sum(nn < 0.05)/nsim)
  message("ESTIMATED EXPONENTIAL  'rejection rate'=", sum(ee < 0.05)/nsim)

The rejection rate for the Gamma is about 5 percent, which matches the 0.05 specified in the conditional. The Normal is about zero, and the Exponential is about 21 percent. The fitted Normal almost always passes for the real parent, though Gamma, for the sample size and amount of L-skewness involved. The Exponential does not. This illustrates that the p-value can be misleading in the single-sample version of this test. Thus when fit by parameters from the sample, the test statistic is nearly always smaller than the one for a prespecified set of parameters. The significance level will be smaller than intended.

Author(s)

W.H. Asquith

References

Csörgő, S., and Faraway, J.J., 1996, The exact and asymptotic distributions of Cramér–von Mises statistics: Journal of the Royal Statistical Society, Series B, v. 58, pp. 221–234.

See Also

lmrdia

Examples

1
2
3
4
5
6
7
# An example in which the test is conducted on a sample but the parent is known.
# This will lead to more precise inference than if the sample parameters are used.
mu <- 120; sd <- 25; para <- vec2par(c(120,25), type="nor")
x <- rnorm(56, mean=mu, sd=sd)
T1 <- cvm.test.lmomco(x, para)$statistic
T2 <- goftest::cvm.test(x, null="pnorm", mean=mu, sd=sd)$statistic
message("Cramer--von Mises: T1=", round(T1, digits=6), " and T2=", round(T2, digits=6))

Example output

Cramer--von Mises: T1=0.227941 and T2=0.227941

lmomco documentation built on Nov. 17, 2017, 7:25 a.m.