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

qqplot_maha

QQ Plot for Multivariate Normal Variance Mixtures


Description

Visual goodness-of-fit test for multivariate normal variance mixtures: Plotting squared Mahalanobis distances against their theoretical quantiles.

Usage

qqplot_maha(x, qmix, loc, scale, plot.diag = TRUE, verbose = TRUE,
            control = list(), ...)

Arguments

x

(n, d)-data matrix.

qmix

see pnvmix().

loc

see pnvmix().

scale

see pnvmix().

plot.diag

logical indicating if the diagonal y=x shall be included in the plot.

verbose

see pnvmix().

control

list specifying algorithm specific parameters; see get_set_param().

...

additional arguments (for example, parameters) passed to the underlying mixing distribution when qmix is a character string or function.

Details

If X follows a multivariate normal variance mixture, the distribution of the Mahalanobis distance D^2 = (X-μ)^T Σ^{-1} (X-μ) is a gamma mixture whose distribution function can be approximated. The function qqplot_maha() plots the empirical Mahalanobis distances from the data in x (with μ=loc and Sigma=scale) versus their theoretical quantiles which are internally estimated via the function qgammamix().

Value

qqplot_maha() (invisibly) returns a list of two: maha2, the sorted Mahalanobis distances of the data in x with respect to loc and scale and q, the theoretical quantiles evaluated at ppoints(n) where n=nrow(x).

Author(s)

Erik Hintz, Marius Hofert and Christiane Lemieux

References

Hintz, E., Hofert, M. and Lemieux, C. (2020), Normal variance mixtures: Distribution, density and parameter estimation. https://arxiv.org/abs/1911.03017.

McNeil, A. J., Frey, R. and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.

See Also

Examples

## Setup
n     <- 15
d     <- 2
df    <- 3.1 # degree-of-freedom parameter
loc   <- rep(0, d)
scale <- diag(d)
## Define the quantile function of an IG(nu/2, nu/2) distribution
qmix <- function(u, df) 1 / qgamma(1 - u, shape = df/2, rate = df/2)
## Sample data
set.seed(1) # for reproducibility
x <- rnvmix(n, qmix = qmix, df = df, loc = loc, scale = scale)
## QQ Plot of empirical quantiles vs true quantiles, all values estimated 
## via RQMC:
qqplot_maha(x, qmix = qmix, loc = loc, scale = scale, df = df)
## Same could be obtained by specifying 'qmix' as string in which case
## qqplot_maha() calls qf()
qqplot_maha(x, qmix = "inverse.gamma", loc = loc, scale = scale, df = df)

nvmix

Multivariate Normal Variance Mixtures

v0.0-5
GPL (>= 3) | file LICENCE
Authors
Marius Hofert [aut, cre], Erik Hintz [aut], Christiane Lemieux [aut]
Initial release

We don't support your browser anymore

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