qntR {DPQ}R Documentation

Pure R Implementation of R's qt() / qnt()

Description

A pure R implementation of R's C API (‘Mathlib’ specifically) qnt() function which computes (non-central) t quantiles.

The simple inversion (of pnt()) scheme has seen to be deficient, even in cases where pnt(), i.e., R's pt(.., ncp=*) does not loose accuracy.

Usage

qntR1(p, df, ncp, lower.tail = TRUE, log.p = FALSE,
      pnt = stats::pt, accu = 1e-13, eps = 1e-11)
qntR (p, df, ncp, lower.tail = TRUE, log.p = FALSE,
      pnt = stats::pt, accu = 1e-13, eps = 1e-11)

Arguments

p, df, ncp

vectors of probabilities, degrees of freedom, and non-centrality parameter; see qt.

lower.tail, log.p

logical; see qt.

pnt

a function for computing the CDF of the (non-central) t-distribution.

accu

a non-negative number, the “accu”racy desired in the "root finding" loop.

eps

a non-negative number, used for determining the start interval for the root finding.

Value

numeric vector of t quantiles, properly recycled in (p, df, ncp).

Author(s)

Martin Maechler

See Also

Our qtU() and qtAppr(); non-central density and probability approximations in dntJKBf, and e.g., pntR. Further, R's qt.

Examples

## example where qt() and qntR() "fail" {warnings; --> Inf}
lp <- seq(-30, -24, by=1/4)
summary(p <- exp(lp))
(qp <- qntR( p, df=35, ncp=-7, lower.tail=FALSE))
qp2 <- qntR(lp, df=35, ncp=-7, lower.tail = FALSE, log.p=TRUE)
all.equal(qp, qp2)## same warnings, same values

[Package DPQ version 0.5-8 Index]