zk.test: The analogue ZK of the Kolmogorov-Smirnov statistic

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

View source: R/zk.test.R

Description

The new statistics ZK appear similar to the Kolmogorov-Smirnov statistic, but it's generally much more powerful,see Jin Zhang(2002).

Usage

1
zk.test(x, y, para = NULL, N = 1000)

Arguments

x

a numeric vector of data values, the number of which must be greater than 7. Missing values are allowed.

y

When tested as a single sample, a numeric vector of data values, the number of which must be greater than 7. Missing values are allowed.

When tested as two-sample, a character string indicating what type of test was performed. Distributions "unif", "exponential", "normal", "lognormal", "gamma","t" and "weibull" are recognised.Here,the names of "exponential", "normal" and "lognormal" are simplified as "exp" ,"norm" and "lognorm" respectively.

para

A named list giving the parameters of the distribution specified and this can be omitted.

N

The number of replications in Monte Carlo simulation.The default value is 1000

Details

The Zk test is an EDF omnibus test for the composite hypothesis of distribution. The test statistic is

Z_{k}=\max \limits_{1 ≤q i ≤q n}\{(i-0.5)\ln\frac{i-0.5}{nF_{0}(X_{(i)})}+(n-i+0.5)\ln\frac{n-i+0.5}{n[1-F_0(X_{(i)})]}\},

where F_{0}(x) is a hypothesized distribution function to be tested.Here, F_{0}(X_{(i)}) = Φ(x), Φ is the cumulative distribution function of the specificed distribution.The p-value is computed by Monte Carlo simulation.

Value

A list with class “htest” containing the following components:

statistic

the value of the ZK statistic.

p.value

the p-value for the test.

method

the character string “ZK test for given distribution”.

data.name

a character string giving the name(s) of the data.

Note

The Zk test is the recommended EDF test by Jin Zhang.

Author(s)

Ning Cui

References

Jin Zhang: Goodness-of-Fit Tests Based on the Likelihood Ratio.Journal of the Royal Statistical Society,64,281-294.

Jin Zhang,Yuehua Wu: Likelihood-ratio tests for normality.Computational Statistics & Data Analysis,49,709-721.

Jin Zhang: Powerful Two-Sample Tests Based on the Likelihood Ratio. Technometrics, 48:1, 95-103.

See Also

ks.test for performing a one- or two-sample Kolmogorov-Smirnov test. zc.test,za.test for performing a powerful goodness-of-fit test based on the likelihood ratio.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x<-rbeta(50,shape1 = 0.6,shape2 = 0.8)
y<-rnorm(50)
zk.test(x,y)
zk.test(x,"unif")
zk.test(x,"norm")
zk.test(x,"unif",para = list(min=1,max=2))
zk.test(x,"exp",para = list(rate=1))
zk.test(x,"norm",para = list(mean=1,sd=2))
zk.test(x,"lognorm",para = list(mean=1,sd=2))
zk.test(x,"weibull",para = list(shape=1,scale=2))
zk.test(x,"gamma",para = list(shape=2,scale=1))
zk.test(x,"t",para = list(df=3))

Example output

	Two-sample Zk test

data:  x and y
Zk = 15.902, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 3.1567, p-value = 0.144


	One-sample Zk test

data:  x
Zk = 3.5459, p-value = 0.002


	One-sample Zk test

data:  x
Zk = 1137, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 20.46, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 31.896, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 55.647, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 43.696, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 63.367, p-value < 2.2e-16


	One-sample Zk test

data:  x
Zk = 32.018, p-value < 2.2e-16

DistributionTest documentation built on Feb. 26, 2020, 9:06 a.m.