Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

QF_ratio

Ratio of Positive Definite Quadratic Forms Distribution


Description

Density function, distribution function, quantile function and random generator for the ratio of positive definite QFs.

Usage

dQF_ratio(x, obj)

pQF_ratio(q, obj)

qQF_ratio(p, obj, eps_quant = 1e-06, maxit_quant = 10000)

rQF_ratio(
  n,
  lambdas_num,
  lambdas_den,
  etas_num = rep(0, length(lambdas_num)),
  etas_den = rep(0, length(lambdas_den))
)

Arguments

x, q

vector of quantiles.

obj

MellinQF_ratio object produced by the compute_MellinQF_ratio function.

p

vector of probabilities.

eps_quant

relative error for quantiles.

maxit_quant

maximum number of Newton-Raphson iterations allowed to compute quantiles.

n

number of observations.

lambdas_num

vector of positive weights of the QF at the numerator.

lambdas_den

vector of positive weights of the QF at the denominator

etas_num

vector of non-centrality parameters of the QF at the numerator. Default all zeros.

etas_den

vector of non-centrality parameters of the QF at the denominator Default all zeros.

Details

The CDF and PDF of the ratio of positive QFs are evaluated by numerical inversion of the Mellin transform. The absolute error specified in compute_MellinQF_ratio is guaranteed for values of q and x inside range_q. If the quantile is outside range_q, computations are carried out, but a warning is sent.

The function uses the Newton-Raphson algorithm to compute the ratio of QFs quantiles related to probabilities p.

Value

dQF_ratio provides the values of the density function at a quantile x.

pQF_ratio provides the cumulative distribution function at a quantile q.

qQF_ratio provides the quantile corresponding to a probability level p.

rQF_ratio provides a sample of n independent realizations the QFs ratio.

See Also

See compute_MellinQF_ratio for details on the Mellin computation.

Examples

lambdas_QF_num <- c(rep(7, 6),rep(3, 2))
etas_QF_num <- c(rep(6, 6), rep(2, 2))
lambdas_QF_den <- c(0.6, 0.3, 0.1)
# Computation Mellin transform
eps <- 1e-7
rho <- 0.999
Mellin_ratio <- compute_MellinQF_ratio(lambdas_QF_num, lambdas_QF_den,
                                       etas_QF_num, eps = eps, rho = rho)
xs <- seq(Mellin_ratio$range_q[1], Mellin_ratio$range_q[2], l = 100)
# PDF
ds <- dQF_ratio(xs, Mellin_ratio)
plot(xs, ds, type="l")
# CDF
ps <- pQF_ratio(xs, Mellin_ratio)
plot(xs, ps, type="l")
# Quantile
qs <- qQF_ratio(ps, Mellin_ratio)
plot(ps, qs, type="l")
#Comparison computed quantiles vs real quantiles
plot((qs - xs) / xs, type = "l")

QF

Density, Cumulative and Quantile Functions of Quadratic Forms

v0.0.4
GPL-3
Authors
Aldo Gardini [aut, cre], Fedele Greco [aut], Carlo Trivisano [aut]
Initial release
2021-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.