moranTest function

Moran's Log Spacings Test

Moran's Log Spacings Test

This function implements a goodness-of-fit test using Moran's log spacings statistic.

moranTest(x, densFn, param = NULL, ...)

Arguments

  • densFn: Character. The root name of the distribution to be tested.
  • x: Numeric. Vector of data to be tested.
  • param: Numeric. A vector giving the parameter values for the distribution specified by densFn. If no param values are specified, then the default parameter values of the distribution are used instead.
  • ...: Additional arguments to allow specification of the parameters of the distribution other than specified by param.

Details

Moran(1951) gave a statistic for testing the goodness-of-fit of a random sample of xx-values to a continuous univariate distribution with cumulative distribution function F(x,theta)F(x, theta), where θ\theta is a vector of known parameters. This function implements the Cheng and Stephens(1989) extended Moran test for unknown parameters.

The test statistic is

T(θ^)=(M(θ^)+1/2kC1)/C2T(thetahat)=(M(thetahat)+1/2kC1)/C2 T(\hat \theta)=(M(\hat\theta)+1/2k-C_1)/C_2T(thetahat)=(M(thetahat)+1/2k-C1)/C2

Where M(θ^)M(\hat \theta), the Moran statistic, is

M(θ)=(log(y1y0)+log(y2y1)++log(ymym1)) M(\theta)=-(\log(y_1-y_0)+\log(y_2-y_1)+\dots+\log(y_m-y_{m-1}))%M(theta)=-(log(y_1-y_0)+log(y_2-y_1)+...+log(y_m-y_m-1))

This test has null hypothesis: H0H_0 : a random sample of nn values of xx comes from distribution F(x,theta)F(x, theta), where thetatheta is the vector of parameters. Here thetatheta is expected to be the maximum likelihood estimate thetahatthetahat, an efficient estimate. The test rejects H0H_0 at significance level alphaalpha if T(thetahat)T(thetahat) > chisq(alpha,df=n)chisq(alpha, df = n).

Returns

  • statistic: Numeric. The value of the Moran test statistic.

  • estimate: Numeric. A vector of parameter estimates for the tested distribution.

  • parameter: Numeric. The degrees of freedom for the Moran statistic.

  • p.value: Numeric. The p-value for the test. - data.name: Character. A character string giving the name(s) of the data.

  • method: Character. Type of test performed.

References

Cheng, R. C. & Stephens, M. A. (1989). A goodness-of-fit test using Moran's statistic with estimated parameters. Biometrika, 76 , 385--92.

Moran, P. (1951). The random division of an interval---PartII. J. Roy. Statist. Soc. B, 13 , 147--50.

Author(s)

David Scott d.scott@auckland.ac.nz , Xinxing Li xli053@aucklanduni.ac.nz

Examples

### Normal Distribution x <- rnorm(100, mean = 0, sd = 1) muhat <- mean(x) sigmahat <- sqrt(var(x)*(100 - 1)/100) result <- moranTest(x, "norm", mean = muhat, sd = sigmahat) result ### Exponential Distribution y <- rexp(200, rate = 3) lambdahat <- 1/mean(y) result <- moranTest(y, "exp", rate = lambdahat) result
  • Maintainer: David Scott
  • License: GPL (>= 2)
  • Last published: 2025-03-29

Useful links