Learn R Programming

MissMech (version 1.0.2)

TestUNey: Test of Goodness of Fit (Uniformity)

Description

This routine tests whether the values in a vector x is distributed as uniform (0,1). The Neyman's smooth test of fit, as described by Ladwina (1994) is used. The p-values are obtained based on a resampling method from uniform (0,1).

Usage

TestUNey(x, nrep = 10000, sim = NA, n.min = 30)

Arguments

x
A vector of values, each in the interval [0,1].
nrep
The number of replications used to simulate the Neyman distribution.
sim
A vector of simulated values from the Neyman distribution. If sim = NA this vector is generated by the function SimNev, otherwise the vector inputted is used.
n.min
The minimum sample size that triggers the use of asymptotic Chi distribution in place of the emprical distribution in the Neyman test of uniformity.

Value

pn
The p-value for the test.
n4
The value of the test statistics.

References

Ledwina, T. (1994). ``Data-driven version of neyman's smooth test of fit,'' Journal of the American Statistical Association, 89, 1000-1005.

Examples

Run this code
# Example 1
x <- runif(100)
TestUNey(x, nrep = 10000, sim = NA)

# Example 2
x <- runif(30,2,5)
x <- (x-min(x))/(max(x)-min(x))
TestUNey(x, nrep = 10000, sim = NA)

# Example 3
x <- c(0.6,0.6,0.5,0.7,0.3,0.4,0.5,0.4,0.2,0.4,0.2,0.5,0.7,0.1,0.7,0.1,0.5,0.5,0.4,0.6,0.3)
TestUNey(x, nrep = 10000, sim = NA)

Run the code above in your browser using DataLab