dproddnf: The product of multiple doubly non-central F's distribution.

View source: R/proddnf.r

proddnfR Documentation

The product of multiple doubly non-central F's distribution.

Description

Density, distribution function, quantile function and random generation for the product of multiple independent doubly non-central F variates.

Usage

dproddnf(x, df1, df2, ncp1, ncp2, log = FALSE, order.max=4)

pproddnf(q, df1, df2, ncp1, ncp2, lower.tail = TRUE, log.p = FALSE, order.max=4)

qproddnf(p, df1, df2, ncp1, ncp2, lower.tail = TRUE, log.p = FALSE, order.max=4)

rproddnf(n, df1, df2, ncp1, ncp2)

Arguments

x, q

vector of quantiles.

df1, df2

the vectors of the degrees of freedom for the numerator and denominator. We do not recycle these versus the x,q,p,n.

ncp1, ncp2

the vectors of the non-centrality parameters for the numerator and denominator. 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

x_j \sim F\left(\delta_{1,j},\delta_{2,j},\nu_{1,j},\nu_{2,j}\right)

be independent doubly non-central F variates with non-centrality parameters \delta_{i,j} and degrees of freedom \nu_{i,j} for i=1,2,\ldots,I and j=1,2. Then

Y = \prod_j x_j

takes a product of doubly non-central F's distribution. We take the parameters of this distribution as the four I length vectors of the two degrees of freedom and the two non-centrality parameters.

Value

dproddnf gives the density, pproddnf gives the distribution function, qproddnf gives the quantile function, and rproddnf 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.

The PDQ functions are computed by translation of the sum of log chi-squares distribution functions.

Author(s)

Steven E. Pav shabbychef@gmail.com

References

Pav, Steven. Moments of the log non-central chi-square distribution. https://arxiv.org/abs/1503.06266

See Also

The sum of log of chi-squares distribution, dsumlogchisq, psumlogchisq, qsumlogchisq, rsumlogchisq. (doubly non-central) F distribution functions, ddnf, pdnf, qdnf, rdnf.

Examples

df1 <- c(10,20,5)
df2 <- c(1000,500,150)
ncp1 <- c(1,0,2.5)
ncp2 <- c(0,1.5,5)

rv <- rproddnf(500, df1=df1,df2=df2,ncp1=ncp1,ncp2=ncp2)
d1 <- dproddnf(rv, df1=df1,df2=df2,ncp1=ncp1,ncp2=ncp2)

plot(rv,d1)

p1 <- pproddnf(rv, df1=df1,df2=df2,ncp1=ncp1,ncp2=ncp2)
# should be nearly uniform:

plot(ecdf(p1))

q1 <- qproddnf(ppoints(length(rv)), df1=df1,df2=df2,ncp1=ncp1,ncp2=ncp2)

qqplot(x=rv,y=q1)


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