psi.Dn: Compute Kolmogorov statistics

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

View source: R/psistat.R

Description

Compute the Kolmogorov statistic and its one-sided variants.

Usage

1
2
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 Dn, '"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.

Author(s)

Georgi N. Boshnakov

See Also

ks.test

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
a1 <- rnorm(10)                # some data
psi.Dn(a1,cdf=pnorm)           # Compute Dn
ks.test(a1,pnorm)$statistic    # should  be the same

psi.Dn(a1,cdf=pnorm,type="D^+")
ks.test(a1,pnorm,alternative="greater")$statistic

psi.Dn(a1,cdf=pnorm,type="D^-")
ks.test(a1,pnorm,alternative="less")$statistic

psi.Dn(a1,cdf=pnorm,mean=2,sd=2.3)  # pnorm with parameters.


a2 <- rexp(10,rate=0.1)           # exponential dist
psi.Dn(a1,cdf=pexp)
psi.Dn(a1,cdf=pexp,rate=0.1)

GeoBosh/psistat documentation built on Nov. 19, 2020, 8:19 p.m.