Compute the Kolmogorov statistic and its one-sided variants.

psi.Dn(x, cdf = pnorm, type = c("D!=", "D^+", "D^-"),
       ties.jitter = NULL, ...)

Arguments

x

numeric; the data vector

cdf

a character string naming a cumulative distribution function or an actual cumulative distribution function such as 'pnorm'.

type

specifies the required variant of the statistic and must be one of '"D!="' (default) for \(D_n\), '"D^+"' for \(D^+\), or '"D^-"' for \(D^-\).

ties.jitter

processing of ties: if NULL (default) no check for ties is done, if TRUE a default jitter is applied to tied values, a numeric value, say a, results in adding a U(-a,a) r.v. to the tied observations.

...

parameters of the distribution function specified by cdf.

Details

The same result may be obtained by extracting the statistic component from the result of ks.test, see the examples. psi.Dn may be convenient for use as part of other calculations since it only computes \(D\).

When there are ties in the data and ties.jitter is not NULL the returned value is random and will vary even if the function is called with the same data.

Value

the value of the requested statistic, a single number.

See also

Examples

a1 <- rnorm(10) # some data psi.Dn(a1,cdf=pnorm) # Compute Dn
#> [1] 0.3340103
ks.test(a1,pnorm)$statistic # should be the same
#> D #> 0.3340103
psi.Dn(a1,cdf=pnorm,type="D^+")
#> [1] 0.01268561
ks.test(a1,pnorm,alternative="greater")$statistic
#> D^+ #> 0.01268561
psi.Dn(a1,cdf=pnorm,type="D^-")
#> [1] 0.3340103
ks.test(a1,pnorm,alternative="less")$statistic
#> D^- #> 0.3340103
psi.Dn(a1,cdf=pnorm,mean=2,sd=2.3) # pnorm with parameters.
#> [1] 0.4647364
a2 <- rexp(10,rate=0.1) # exponential dist psi.Dn(a1,cdf=pexp)
#> [1] 0.3
psi.Dn(a1,cdf=pexp,rate=0.1)
#> [1] 0.7996587