qnvmix {nvmix} | R Documentation |
Quantile Function of a univariate Normal Variance Mixture Distribution
Description
Evaluating multivariate normal variance mixture distribution functions (including normal and Student t for non-integer degrees of freedom).
Usage
qnvmix(u, qmix, control = list(),
verbose = TRUE, q.only = TRUE, stored.values = NULL, ...)
Arguments
u |
vector of probabilities . |
qmix |
specification of the mixing variable |
control |
|
verbose |
|
q.only |
|
stored.values |
|
... |
additional arguments containing parameters of
mixing distributions when |
Details
This function uses a Newton procedure to estimate the quantile of the
specified univariate normal variance mixture distribution. Internally,
a randomized quasi-Monte Carlo (RQMC) approach is used to estimate the
distribution and (log)density function; the method is similar to the
one in pnvmix()
and dnvmix()
. The result depends
slightly on .random.seed
.
Internally, symmetry is used for u \le 0.5
. Function values
(i.e., df and log-density values) are stored and reused to get good
starting values. These values are returned if q.only = FALSE
and can be re-used by passing it to qnvmix()
via the argument
stored.values
; this can significantly reduce run-time.
Accuracy and run-time depend on both the magnitude of u
and on
how heavy the tail of the underlying distributions is. Numerical
instabilities can occur for values of u
close to 0 or 1,
especially when the tail of the distribution is heavy.
If q.only = FALSE
the log-density values of the underlying
distribution evaluated at the estimated quantiles are returned as
well: This can be useful for copula density evaluations where both
quantities are needed.
Underlying algorithm specific parameters can be changed via the control
argument, see get_set_param()
for details.
Value
If q.only = TRUE
a vector of the same length as u
with
entries q_i
where q_i
satisfies q_i = inf_x { F(x)
\ge u_i}
where F(x)
the univariate df of the normal variance
mixture specified via qmix
;
if q.only = FALSE
a list of four:
$q
:Vector of quantiles,
$log.density
:vector log-density values at
q
,$computed.values
:matrix with 3 columns [x, F(x), logf(x)]; see details above,
$newton.iterations
:vector giving the number of Newton iterations needed for
u[i]
.
Author(s)
Erik Hintz, Marius Hofert and Christiane Lemieux
References
Hintz, E., Hofert, M. and Lemieux, C. (2021), Normal variance mixtures: Distribution, density and parameter estimation. Computational Statistics and Data Analysis 157C, 107175.
Hintz, E., Hofert, M. and Lemieux, C. (2022), Multivariate Normal Variance Mixtures in R: The R Package nvmix. Journal of Statistical Software, doi:10.18637/jss.v102.i02.
McNeil, A. J., Frey, R., and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.
See Also
Examples
## Evaluation points
u <- seq(from = 0.05, to = 0.95, by = 0.025)
set.seed(271) # for reproducibility
## Evaluate the t_{1.4} quantile function
df <- 1.4
qmix. <- function(u) 1/qgamma(1-u, shape = df/2, rate = df/2)
## If qmix = "inverse.gamma", qt() is being called
qt1 <- qnvmix(u, qmix = "inverse.gamma", df = df)
## Estimate quantiles (without using qt())
qt1. <- qnvmix(u, qmix = qmix., q.only = FALSE)
stopifnot(all.equal(qt1, qt1.$q, tolerance = 2.5e-3))
## Look at absolute error:
abs.error <- abs(qt1 - qt1.$q)
plot(u, abs.error, type = "l", xlab = "u", ylab = "Absolute error")
## Now do this again but provide qt1.$stored.values, in which case at most
## one Newton iteration will be needed:
qt2 <- qnvmix(u, qmix = qmix., stored.values = qt1.$computed.values, q.only = FALSE)
stopifnot(max(qt2$newton.iterations) <= 1)