dsumlogchisq: The sum of the logs of (non-central) chi-squares...

View source: R/sumlogchisq.r

sumlogchisqR Documentation

The sum of the logs of (non-central) chi-squares distribution.

Description

Density, distribution function, quantile function and random generation for the distribution of the weighted sum of logs of non-central chi-squares.

Usage

dsumlogchisq(x, wts, df, ncp=0, log = FALSE, order.max=6)

psumlogchisq(q, wts, df, ncp=0, lower.tail = TRUE, log.p = FALSE, order.max=6)

qsumlogchisq(p, wts, df, ncp=0, lower.tail = TRUE, log.p = FALSE, order.max=6)

rsumlogchisq(n, wts, df, ncp=0)

Arguments

x, q

vector of quantiles.

wts

the vector of weights. This is recycled against the df, ncp, but not against the x,q,p,n.

df

the vector of degrees of freedom. This is recycled against the wts, ncp, but not against the x,q,p,n.

ncp

the vector of non-centrality parameters. This is recycled against the wts, df, but not against 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_i \sim \chi^2\left(\delta_i, \nu_i\right) be independently distributed non-central chi-squares, where \nu_i are the degrees of freedom, and \delta_i are the non-centrality parameters. Let w_i be given constants. Suppose

Y = \sum_i w_i \log X_i.

Then Y follows a weighted sum of log of chi-squares distribution.

Value

dsumlogchisq gives the density, psumlogchisq gives the distribution function, qsumlogchisq gives the quantile function, and rsumlogchisq 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

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

See Also

The product of chi-squares to a power, dprodchisqpow, pprodchisqpow, qprodchisqpow, rprodchisqpow.

Examples

wts <- c(1,-3,4)
df <- c(100,20,10)
ncp <- c(5,3,1)
rvs <- rsumlogchisq(128, wts, df, ncp)
dvs <- dsumlogchisq(rvs, wts, df, ncp)
qvs <- psumlogchisq(rvs, wts, df, ncp)
pvs <- qsumlogchisq(ppoints(length(rvs)), wts, df, ncp)

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