Functions implementing the two Wiener germ approximations to
pchisq()
, the (non-central) chi-squared distribution, and to
qchisq()
its inverse, the quantile function.
These have been proposed by Penev and Raykov (2000) who also listed a Fortran implementation.
In order to use them in numeric boundary cases, Martin Maechler has improved the original formulas.
Auxiliary functions:
sW()
:The \(s()\) as in the Wienergerm approximation,
but using Taylor expansion when needed, i.e., (x*ncp / df^2) << 1
.
qs()
:...
z0()
:...
z.f()
:...
z.s()
:...
.................. ..................
pchisqW. (q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE,
Fortran = TRUE, variant = c("s", "f"))
pchisqV (q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE,
Fortran = TRUE, variant = c("s", "f"))
pchisqW (q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE, variant = c("s", "f"))
pchisqW.R(x, df, ncp = 0, lower.tail = TRUE, log.p = FALSE, variant = c("s", "f"),
verbose = getOption("verbose"))sW(x, df, ncp)
qs(x, df, ncp, f.s = sW(x, df, ncp), eps1 = 1/2, sMax = 1e+100)
z0(x, df, ncp)
z.f(x, df, ncp)
z.s(x, df, ncp, verbose = getOption("verbose"))
all these functions return numeric
vectors according to
their arguments.
vector of quantiles (main argument, see pchisq
).
degrees of freedom (non-negative, but can be non-integer).
non-centrality parameter (non-negative).
a character
string, currently either
"f"
for the first or
"s"
for the second Wienergerm approximation in
Penev and Raykov (2000).
logical specifying if the Fortran or the C version should be used.
logical (or integer) indicating if or how much diagnostic output should be printed to the console during the computations.
a number must be a “version” of \(s(x, df, ncp)\).
for qs()
: use direct approximation instead of
h(1 - 1/s)
for s < eps1
.
for qs()
: cutoff to switch the \(h(.)\) formula for
s > sMax
.
Martin Maechler, mostly end of Jan 2004
....TODO... or write vignette
Penev, Spiridon and Raykov, Tenko (2000) A Wiener Germ approximation of the noncentral chi square distribution and of its quantiles. Computational Statistics 15, 219--228. tools:::Rd_expr_doi("10.1007/s001800000029")
Dinges, H. (1989) Special cases of second order Wiener germ approximations. Probability Theory and Related Fields, 83, 5--57.
## see example(pnchisqAppr) which looks at all of the pchisq() approximating functions
Run the code above in your browser using DataLab