dnt R Documentation

The doubly non-central t distribution.

Description

Density, distribution function, quantile function and random generation for the doubly non-central t distribution.

Usage

ddnt(x, df, ncp1, ncp2, log = FALSE, order.max=6)

pdnt(q, df, ncp1, ncp2, lower.tail = TRUE, log.p = FALSE, order.max=6)

qdnt(p, df, ncp1, ncp2, lower.tail = TRUE, log.p = FALSE, order.max=6)

rdnt(n, df, ncp1, ncp2)


Arguments

 x, q vector of quantiles. df the degrees of freedom for the denominator, \nu. We do not recycle these versus the x,q,p,n. ncp1, ncp2 the non-centrality parameters for the numerator and denominator, respectively, \mu and \theta We do not recycle these versus the x,q,p,n. log logical; if TRUE, densities f are given as \mbox{log}(f). order.max the order to use in the approximate density, distribution, and quantile computations, via the Gram-Charlier, Edeworth, or Cornish-Fisher expansion. p vector of probabilities. n number of observations. log.p logical; if TRUE, probabilities p are given as \mbox{log}(p). lower.tail logical; if TRUE (default), probabilities are P[X \le x], otherwise, P[X > x].

Details

Let Z \sim \mathcal{N}\left(\mu,1\right) independently of X \sim \chi^2\left(\theta,\nu\right). The random variable

T = \frac{Z}{\sqrt{X/\nu}}

takes a doubly non-central t distribution with parameters \nu, \mu, \theta.

Value

ddnt gives the density, pdnt gives the distribution function, qdnt gives the quantile function, and rdnt generates random deviates.

Invalid arguments will result in return value NaN with a warning.

Note

The PDF, CDF, and quantile function are approximated, via the Edgeworth or Cornish Fisher approximations, which may not be terribly accurate in the tails of the distribution. You are warned.

The distribution parameters are not recycled with respect to the x, p, q or n parameters, for, respectively, the density, distribution, quantile and generation functions. This is for simplicity of implementation and performance. It is, however, in contrast to the usual R idiom for dpqr functions.

Author(s)

Steven E. Pav shabbychef@gmail.com

References

Krishnan, Marakatha. "Series Representations of the Doubly Noncentral t-Distribution." Journal of the American Statistical Association 63, no. 323 (1968): 1004-1012.

t distribution functions, dt, pt, qt, rt

Examples

rvs <- rdnt(128, 20, 1, 1)
dvs <- ddnt(rvs, 20, 1, 1)
pvs.H0 <- pdnt(rvs, 20, 0, 1)
pvs.HA <- pdnt(rvs, 20, 1, 1)

plot(ecdf(pvs.H0))
plot(ecdf(pvs.HA))

# compare to singly non-central
dv1 <- ddnt(1, df=10, ncp1=5, ncp2=0, log=FALSE)
dv2 <- dt(1, df=10, ncp=5, log=FALSE)
pv1 <- pdnt(1, df=10, ncp1=5, ncp2=0, log.p=FALSE)
pv11 <- pdnt(1, df=10, ncp1=5, ncp2=0.001, log.p=FALSE)
v2 <- pt(1, df=10, ncp=5, log.p=FALSE)

q1 <- qdnt(pv1, df=10, ncp1=5, ncp2=0, log.p=FALSE)


sadists documentation built on Aug. 22, 2023, 1:06 a.m.