Learn R Programming

DistributionUtils (version 0.6-1)

moranTest: Moran's Log Spacings Test

Description

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

Usage

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

Value

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.

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.

Author

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

Details

Moran(1951) gave a statistic for testing the goodness-of-fit of a random sample of \(x\)-values to a continuous univariate distribution with cumulative distribution function \(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(\hat \theta)=(M(\hat \theta)+1/2k-C_1)/C_2$$ Where \(M(\hat \theta)\), the Moran statistic, is $$M(\theta)=-(log(y_1-y_0)+log(y_2-y_1)+...+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: \(H_0\) : a random sample of \(n\) values of \(x\) comes from distribution \(F(x, \theta)\), where \(\theta\) is the vector of parameters. Here \(\theta\) is expected to be the maximum likelihood estimate \(\hat \theta\), an efficient estimate. The test rejects \(H_0\) at significance level \(\alpha\) if \(T(\hat \theta)\) > \(\chi^2_n(\alpha)\).

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.

Examples

Run this code

### 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

Run the code above in your browser using DataLab