Fitting Multivariate Normal Variance Mixtures
Functionalities for fitting multivariate normal variance mixtures (in particular also Multivariate t distributions) via an ECME algorithm.
fitnvmix(x, qmix, mix.param.bounds, nu.init = NA, loc = NULL, scale = NULL,
init.size.subsample = min(n, 100), size.subsample = n,
control = list(), verbose = TRUE)
fitStudent(x, loc = NULL, scale = NULL, mix.param.bounds = c(1e-3, 1e2), ...)
fitNorm(x)x |
(n, d)-data |
qmix |
specification of the mixing variable W; see McNeil et al. (2015, Chapter 6). Supported are the following types of specification (see also the examples below):
|
mix.param.bounds |
either |
nu.init |
either |
loc |
d- |
scale |
positive definite (d, d)- |
init.size.subsample |
|
size.subsample |
|
control |
|
verbose |
|
... |
additional arguments passed to the underlying
|
The function fitnvmix() uses an ECME algorithm to approximate the
MLEs of the parameters nu, loc and scale of a
normal variance mixture specified by qmix. The underlying
procedure successively estimates nu (with given loc and
scale) by maximizing the likelihood which is approximated by
dnvmix() (unless qmix is a character
string, in which case analytical formulas for the log-densities are
used) and scale and loc (given nu) using weights
(which again need to be approximated) related to the posterior
distribution, details can be found in the first reference below.
It should be highlighted that (unless unless qmix is a
character string), every log-likelihood and every weight needed
in the estimation is numerically approximated via RQMC methods. For
large dimensions and sample sizes this procedure can therefore be
slow.
Various tolerances and convergence criteria can be changed by the user
via the control argument. For more details, see
get_set_param().
nuEstimated mixing parameter (vector) nu.
locEstimated or provided loc vector.
scaleEstimated or provided scale matrix.
max.llEstimated log-likelihood at reported estimates.
The methods print(), summary() and plot() are defined
for the class "fitnvmix".
fitStudent() is a wrapper to fitnvmix() for parameter
estimation of multivariate Student t distributions; it also
returns an S3 object of class "fitnvmix" where
the fitted degrees of freedom are called "df" instead of
"nu" (to be consistent
with the other wrappers for the Student t distributions).
fitNorm() just returns a list with components
loc (columnwise sample means) and scale (sample
covariance matrix).
Erik Hintz, Marius Hofert and Christiane Lemieux
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.
Liu, C. and Rubin, D. (1994). The ECME algorithm: a simple extension of EM and ECM with faster monotone convergence. Biometrika 81(4), 633–648.
dnvmix(), rnvmix(), pnvmix(),
qqplot_maha(), get_set_param().
## Sampling parameters
set.seed(274) # for reproducibility
nu <- 2.8 # parameter used to sample data
d <- 4 # dimension
n <- 75 # small sample size to have examples run fast
loc <- rep(0, d) # location vector
A <- matrix(runif(d * d), ncol = d)
diag_vars <- diag(runif(d, min = 2, max = 5))
scale <- diag_vars %*% cov2cor(A %*% t(A)) %*% diag_vars # scale matrix
mix.param.bounds <- c(1, 5) # nu in [1, 5]
### Example 1: Fitting a multivariate t distribution ###########################
if(FALSE){
## Define 'qmix' as the quantile function of an IG(nu/2, nu/2) distribution
qmix <- function(u, nu) 1 / qgamma(1 - u, shape = nu/2, rate = nu/2)
## Sample data using 'rnvmix'
x <- rnvmix(n, qmix = qmix, nu = nu, loc = loc, scale = scale)
## Call 'fitvnmix' with 'qmix' as a function (so all densities/weights are estimated)
(MyFit11 <- fitnvmix(x, qmix = qmix, mix.param.bounds = mix.param.bounds))
## Call 'fitnvmix' with 'qmix = "inverse.gamma"' in which case analytical formulas
## for weights and densities are used:
(MyFit12 <- fitnvmix(x, qmix = "inverse.gamma",
mix.param.bounds = mix.param.bounds))
## Alternatively, use the wrapper 'fitStudent()'
(MyFit13 <- fitStudent(x))
## Check
stopifnot(all.equal(MyFit11$nu, MyFit12$nu, MyFit13$nu, tol = 5e-2))
## Can also provide 'loc' and 'scale' in which case only 'nu' is estimated
(MyFit13 <- fitnvmix(x, qmix = "inverse.gamma", mix.param.bounds = mix.param.bounds,
loc = loc, scale = scale))
(MyFit14 <- fitStudent(x, loc = loc, scale = scale))
stopifnot(all.equal(MyFit13$nu, MyFit14$df, tol = 1e-6))
}
### Example 2: Fitting a Pareto mixture ########################################
## Define 'qmix' as the quantile function of a Par(nu, 1) distribution
qmix <- function(u, nu) (1-u)^(-1/nu)
## Sample data using 'rnvmix':
x <- rnvmix(n, qmix = qmix, nu = nu, loc = loc, scale = scale)
## Call 'fitvnmix' with 'qmix' as function (=> densities/weights estimated)
(MyFit21 <- fitnvmix(x, qmix = qmix, mix.param.bounds = mix.param.bounds))
## Call 'fitnvmix' with 'qmix = "pareto"' in which case an analytical formula
## for the density is used
(MyFit22 <- fitnvmix(x, qmix = "pareto", mix.param.bounds = mix.param.bounds))
stopifnot(all.equal(MyFit21$nu, MyFit22$nu, tol = 5e-2))Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.