Title: | Measuring Copula-Based Dependence Between Random Vectors |
---|---|
Description: | Provides functions for estimation (parametric, semi-parametric and non-parametric) of copula-based dependence coefficients between a finite collection of random vectors, including phi-dependence measures and Bures-Wasserstein dependence measures. An algorithm for agglomerative hierarchical variable clustering is also implemented. Following the articles De Keyser & Gijbels (2024) <doi:10.1016/j.jmva.2024.105336>, De Keyser & Gijbels (2024) <doi:10.1016/j.ijar.2023.109090>, and De Keyser & Gijbels (2024) <doi:10.48550/arXiv.2404.07141>. |
Authors: | Steven De Keyser [aut, cre] , Irène Gijbels [ctb] |
Maintainer: | Steven De Keyser <[email protected]> |
License: | GPL-3 |
Version: | 0.1.3 |
Built: | 2024-11-15 09:23:05 UTC |
Source: | CRAN |
This function computes the non-parametric beta kernel copula density estimator.
betakernelestimator(input, h, pseudos)
betakernelestimator(input, h, pseudos)
input |
The copula argument at which the density estimate is to be computed. |
h |
The bandwidth to be used in the beta kernel. |
pseudos |
The (estimated) copula observations from a |
Given a -dimensional random vector
with
,
and samples
from
for
and
,
the beta kernel estimator for the copula density of
equals, at
,
where is a bandwidth parameter,
with
the (rescaled) empirical cdf of , and
with the beta function.
The beta kernel copula density estimator evaluated at the input.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
transformationestimator
for the computation of the Gaussian transformation kernel copula density estimator,
hamse
for local bandwidth selection for the beta kernel or Gaussian transformation kernel copula density estimator,
phinp
for fully non-parametric estimation of the -dependence between
random vectors.
q = 3 n = 100 # Sample from multivariate normal distribution with identity covariance matrix sample = mvtnorm::rmvnorm(n,rep(0,q),diag(3),method = "chol") # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Argument at which to estimate the density input = rep(0.5,q) # Local bandwidth selection h = hamse(input,pseudos = pseudos,n = n,estimator = "beta",bw_method = 1) # Beta kernel estimator est_dens = betakernelestimator(input,h,pseudos) # True density true = copula::dCopula(input, copula::normalCopula(0, dim = q))
q = 3 n = 100 # Sample from multivariate normal distribution with identity covariance matrix sample = mvtnorm::rmvnorm(n,rep(0,q),diag(3),method = "chol") # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Argument at which to estimate the density input = rep(0.5,q) # Local bandwidth selection h = hamse(input,pseudos = pseudos,n = n,estimator = "beta",bw_method = 1) # Beta kernel estimator est_dens = betakernelestimator(input,h,pseudos) # True density true = copula::dCopula(input, copula::normalCopula(0, dim = q))
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the correlation-based Bures-Wasserstein coefficient
between
given the entire correlation matrix
.
bwd1(R, dim)
bwd1(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
Given a correlation matrix
the coefficient equals
where stands for the Bures-Wasserstein distance,
denotes the set of all correlation matrices
with diagonal blocks
for
, and
is the identity matrix.
The underlying assumption is that the copula of
is Gaussian.
The first Bures-Wasserstein dependence coefficient between
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient ,
bwd1avar
for the computation of the asymptotic variance of the plug-in estimator for .
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd1(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd1(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function simulates a sample from the asymptotic distribution of the plug-in estimator for the correlation-based Bures-Wasserstein coefficient
between
given that the entire correlation matrix
is equal to
(correlation matrix under independence of
).
The argument dim should be in ascending order.
This function requires importation of the python modules "numpy" and "scipy".
bwd1asR0(R, dim, M)
bwd1asR0(R, dim, M)
R |
The correlation matrix of |
dim |
The vector of dimensions |
M |
The sample size. |
A sample of size M is drawn from the asymptotic distribution of the plug-in estimator at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
To create a Python virtual environment with "numpy" and "scipy", run:
install_tensorflow()
reticulate::use_virtualenv("r-tensorflow", required = FALSE)
reticulate::py_install("numpy")
reticulate::py_install("scipy")
A sample of size M from the asymptotic distribution of the plug-in estimator for the first Bures-Wasserstein dependence coefficient under independence of
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient ,
bwd1avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd2avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd2asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
estR
for the computation of the sample matrix of normal scores rank correlations,
otsort
for rearranging the columns of sample such that dim is in ascending order.
q = 5 dim = c(2,3) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) R0 = createR0(R,dim) # Check whether scipy module is available (see details) have_scipy = reticulate::py_module_available("scipy") if(have_scipy){ sample = bwd1asR0(R0,dim,1000) }
q = 5 dim = c(2,3) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) R0 = createR0(R,dim) # Check whether scipy module is available (see details) have_scipy = reticulate::py_module_available("scipy") if(have_scipy){ sample = bwd1asR0(R0,dim,1000) }
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the asymptotic variance of the plug-in estimator for the correlation-based Bures-Wasserstein coefficient
between
given the entire correlation matrix
.
The argument dim should be in ascending order.
bwd1avar(R, dim)
bwd1avar(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
The asymptotic variance of the plug-in estimator is computed at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
The asymptotic variance of the plug-in estimator for the first Bures-Wasserstein dependence coefficient between
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient ,
bwd2avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd1asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
bwd2asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
estR
for the computation of the sample matrix of normal scores rank correlations,
otsort
for rearranging the columns of sample such that dim is in ascending order.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd1avar(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd1avar(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the correlation-based Bures-Wasserstein coefficient
between
given the entire correlation matrix
.
bwd2(R, dim)
bwd2(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
Given a correlation matrix
the coefficient equals
where stands for the Bures-Wasserstein distance,
denotes the set of all correlation matrices
with diagonal blocks
for
, and the matrix
is the correlation matrix under independence.
The underlying assumption is that the copula of
is Gaussian.
The second Bures-Wasserstein dependence coefficient between
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2avar
for the computation of the asymptotic variance of the plug-in estimator for .
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd2(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd2(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function simulates a sample from the asymptotic distribution of the plug-in estimator for the correlation-based Bures-Wasserstein coefficient
between
given that the entire correlation matrix
is equal to
(correlation matrix under independence of
).
The argument dim should be in ascending order.
This function requires importation of the python modules "numpy" and "scipy".
bwd2asR0(R, dim, M)
bwd2asR0(R, dim, M)
R |
The correlation matrix of |
dim |
The vector of dimensions |
M |
The sample size. |
A sample of size M is drawn from the asymptotic distribution of the plug-in estimator at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
To create a Python virtual environment with "numpy" and "scipy", run:
install_tensorflow()
reticulate::use_virtualenv("r-tensorflow", required = FALSE)
reticulate::py_install("numpy")
reticulate::py_install("scipy")
A sample of size M from the asymptotic distribution of the plug-in estimator for the second Bures-Wasserstein dependence coefficient under independence of
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient ,
bwd1avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd2avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd1asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
estR
for the computation of the sample matrix of normal scores rank correlations,
otsort
for rearranging the columns of sample such that dim is in ascending order.
q = 5 dim = c(2,3) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) R0 = createR0(R,dim) # Check whether scipy module is available (see details) have_scipy = reticulate::py_module_available("scipy") if(have_scipy){ sample = bwd2asR0(R0,dim,1000) }
q = 5 dim = c(2,3) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) R0 = createR0(R,dim) # Check whether scipy module is available (see details) have_scipy = reticulate::py_module_available("scipy") if(have_scipy){ sample = bwd2asR0(R0,dim,1000) }
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the asymptotic variance of the plug-in estimator for the correlation-based Bures-Wasserstein coefficient
between
given the entire correlation matrix
.
The argument dim should be in ascending order.
bwd2avar(R, dim)
bwd2avar(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
The asymptotic variance of the plug-in estimator is computed at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
The asymptotic variance of the plug-in estimator for the second Bures-Wasserstein dependence coefficient between
.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient ,
bwd1avar
for the computation of the asymptotic variance of the plug-in estimator for ,
bwd1asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
bwd2asR0
for sampling from the asymptotic distribution of the plug-in estimator for under the hypothesis of independence between
,
estR
for the computation of the sample matrix of normal scores rank correlations,
otsort
for rearranging the columns of sample such that dim is in ascending order.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd2avar(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) bwd2avar(R,dim)
This function computes the empirical penalized Gaussian copula covariance matrix with the Gaussian log-likelihood plus a lasso-type penalty as objective function. Model selection is done by choosing omega such that BIC is maximal.
covgpenal( S, n, omegas, derpenal = function(t, omega) { derSCAD(t, omega, 3.7) }, nsteps = 1 )
covgpenal( S, n, omegas, derpenal = function(t, omega) { derSCAD(t, omega, 3.7) }, nsteps = 1 )
S |
The sample matrix of normal scores covariances. |
n |
The sample size. |
omegas |
The candidate values for the tuning parameter in |
derpenal |
The derivative of the penalty function to be used (default = scad with parameter |
nsteps |
The number of weighted covariance graphical lasso iterations (default = 1). |
The aim is to solve/compute
where the penalty function is of lasso-type:
for a certain penalty function with penalty parameter
, and
the
'th entry of
with
if
and
if
(in order to not shrink the variances).
The matrix
is the matrix of sample normal scores covariances.
In case is the lasso penalty, the implementation for the
(weighted) covariance graphical lasso is available in the R package ‘covglasso’ (see the manual for further explanations). For general penalty functions,
we perform a local linear approximation to the penalty function and iteratively do (nsteps, default = 1) weighted covariance graphical lasso optimizations.
The default for the penalty function is the scad (derpenal = derivative of scad penalty), i.e.,
with by default.
For tuning , we maximize (over a grid of candidate values) the BIC criterion
where is the estimated candidate covariance matrix using
and df (degrees of freedom) equals the number of non-zero entries in
, not taking the elements under the diagonal into account.
A list with elements "est" containing the (lasso-type) penalized matrix of sample normal scores rank correlations (output as provided by the function “covglasso.R”), and "omega" containing the optimal tuning parameter.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
Fop, M. (2021). covglasso: sparse covariance matrix estimation, R package version 1.0.3. url: https://CRAN.R-project.org/package=covglasso.
Wang, H. (2014). Coordinate descent algorithm for covariance graphical lasso. Statistics and Computing 24:521-529. doi: https://doi.org/10.1007/s11222-013-9385-5.
grouplasso
for group lasso estimation of the normal scores rank correlation matrix.
q = 10 dim = c(5,5) n = 100 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sparsity on off-diagonal blocks R0 = createR0(R,dim) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R0,method = "chol") # Normal scores scores = matrix(0,n,q) for(j in 1:q){scores[,j] = qnorm((n/(n+1)) * ecdf(sample[,j])(sample[,j]))} # Sample matrix of normal scores covariances Sigma_est = cov(scores) * ((n-1)/n) # Candidate tuning parameters omega = seq(0.01, 0.6, length = 50) Sigma_est_penal = covgpenal(Sigma_est,n,omega)
q = 10 dim = c(5,5) n = 100 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sparsity on off-diagonal blocks R0 = createR0(R,dim) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R0,method = "chol") # Normal scores scores = matrix(0,n,q) for(j in 1:q){scores[,j] = qnorm((n/(n+1)) * ecdf(sample[,j])(sample[,j]))} # Sample matrix of normal scores covariances Sigma_est = cov(scores) * ((n-1)/n) # Candidate tuning parameters omega = seq(0.01, 0.6, length = 50) Sigma_est_penal = covgpenal(Sigma_est,n,omega)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function constructs the correlation matrix under independence of
, given the entire correlation matrix
.
createR0(R, dim)
createR0(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
Given a correlation matrix
the matrix , being the correlation matrix
under independence of
, is returned.
The correlation matrix under independence of .
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) createR0(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) createR0(R,dim)
This functions selects the omega tuning parameter for ridge penalization of the empirical Gaussian copula correlation matrix via cross-validation. The objective function is the Gaussian log-likelihood, and a grid search is performed using K folds.
cvomega(sample, omegas, K)
cvomega(sample, omegas, K)
sample |
A sample from a |
omegas |
A grid of candidate penalty parameters in |
K |
The number of folds to be used. |
The loss function is the Gaussian log-likelihood, i.e., given an estimated (penalized)
Gaussian copula correlation matrix (normal scores rank correlation matrix) computed on a training set leaving out fold j, and
the empirical (non-penalized)
Gaussian copula correlation matrix computed on test fold j, we search for the tuning parameter that minimizes
The underlying assumption is that the copula of is Gaussian.
The optimal ridge penalty parameter minimizing the cross-validation error.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
Warton, D.I. (2008).
Penalized normal likelihood and ridge regularization of correlation and covariance matrices.
Journal of the American Statistical Association 103(481):340-349.
doi: https://doi.org/10.1198/016214508000000021.
estR
for computing the (Ridge penalized) empirical Gaussian copula correlation matrix.
q = 10 n = 50 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # 5-fold cross-validation with Gaussian likelihood as loss for selecting omega omega = cvomega(sample = sample,omegas = seq(0.01,0.999,len = 50),K = 5) R_est = estR(sample,omega = omega)
q = 10 n = 50 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # 5-fold cross-validation with Gaussian likelihood as loss for selecting omega omega = cvomega(sample = sample,omegas = seq(0.01,0.999,len = 50),K = 5) R_est = estR(sample,omega = omega)
This functions performs improved kernel density estimation of the generator of a meta-elliptical copula by using Liebscher's algorithm, combined with a shrinkage function.
ellcopest( dataU, Sigma_m1, h, grid, niter = 10, a, Kernel = "epanechnikov", shrink, verbose = 1, startPoint = "identity", prenormalization = FALSE, normalize = 1 )
ellcopest( dataU, Sigma_m1, h, grid, niter = 10, a, Kernel = "epanechnikov", shrink, verbose = 1, startPoint = "identity", prenormalization = FALSE, normalize = 1 )
dataU |
The (estimated) copula observations from a |
Sigma_m1 |
The (estimated) inverse of the scale matrix of the meta-elliptical copula. |
h |
The bandwidth of the kernel. |
grid |
The grid of values on which to estimate the density generator. |
niter |
The number of iterations used in the MECIP (default = 10). |
a |
The tuning parameter to improve the performance at |
Kernel |
The kernel used for the smoothing (default = "epanechnikov"). |
shrink |
The shrinkage function to further improve the performance at |
verbose |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
startPoint |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
prenormalization |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
normalize |
A value in |
The context is the one of a -dimensional random vector
,
with for
, having a meta-elliptical copula.
This means that there exists a generator
and a quantile function
, such that the random vector
with
for ,
where
is the cdf of
, has a multivariate elliptical distribution.
Denoting
for the (rescaled) empirical cdf of
based on a sample
for
and
,
and
for an estimator of the scale matrix
, this function estimates
by using the MECIP (Meta-Elliptical Copula Iterative Procedure) of Derumigny & Fermanian (2022).
This means that we start from an initial guess for the generator
, based on which we obtain an estimated
sample from
through the quantile function corresponding to
.
Based on this estimated sample, we then obtain an estimator
using the function
elldistrest
, performing improved kernel estimation with shrinkage function.
This procedure is repeated for a certain amount (niter) of iterations to obtain a final estimate for .
The estimator without the shrinkage function is implemented in the R package ‘ElliptCopulas’.
We use this implementation and bring in the shrinkage function.
In order to make identifiable, an extra normalization procedure is implemented
in line with an extra constraint on
.
When normalize = 1, this corresponds to
being the correlation matrix of
.
When normalize = 2, this corresponds to the identifiability condition of Derumigny & Fermanian (2022).
The estimates for at the grid points.
Derumigny, A., Fermanian, J.-D., Ryan, V., van der Spek, R. (2024). ElliptCopulas, R package version 0.1.4.1. url: https://CRAN.R-project.org/package=ElliptCopulas.
Derumigny, A. & Fermanian, J.-D. (2022).
Identifiability and estimation of meta-elliptical copula generators.
Journal of Multivariate Analysis 190:104962.
doi: https://doi.org/10.1016/j.jmva.2022.104962.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
Liebscher, E. (2005). A semiparametric density estimator based on elliptical distributions. Journal of Multivariate Analysis 92(1):205-225. doi: https://doi.org/10.1016/j.jmva.2003.09.007.
elldistrest
for improved kernel estimation of the elliptical generator of an elliptical distribution,
elliptselect
for selecting optimal tuning parameters for the improved kernel estimator of the elliptical generator,
phiellip
for estimating the -dependence between
random vectors having a meta-elliptical copula.
q = 4 # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Shrinkage function shrinkage = function(t,p){1-(1/((t^p) + 1))} # Tuning parameter selection opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters a = opt_parameters$Opta ; p = opt_parameters$Optp ; h = opt_parameters$Opth # Estimated elliptical generator g_est = ellcopest(dataU = pseudos,Sigma_m1 = diag(q),h = h,grid = grid,a = a, shrink = function(t){shrinkage(t,p)}) plot(grid,g_est,type = "l", xlim = c(0,8)) lines(grid,g_q,col = "green")
q = 4 # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Shrinkage function shrinkage = function(t,p){1-(1/((t^p) + 1))} # Tuning parameter selection opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters a = opt_parameters$Opta ; p = opt_parameters$Optp ; h = opt_parameters$Opth # Estimated elliptical generator g_est = ellcopest(dataU = pseudos,Sigma_m1 = diag(q),h = h,grid = grid,a = a, shrink = function(t){shrinkage(t,p)}) plot(grid,g_est,type = "l", xlim = c(0,8)) lines(grid,g_q,col = "green")
This functions performs improved kernel density estimation of the generator of an elliptical distribution by using Liebscher's algorithm, combined with a shrinkage function.
elldistrest( Z, mu = 0, Sigma_m1, grid, h, Kernel = "epanechnikov", a, shrink, mpfr = FALSE, precBits = 100, dopb = FALSE, normalize = 1 )
elldistrest( Z, mu = 0, Sigma_m1, grid, h, Kernel = "epanechnikov", a, shrink, mpfr = FALSE, precBits = 100, dopb = FALSE, normalize = 1 )
Z |
A sample from a |
mu |
The (estimated) mean of |
Sigma_m1 |
The (estimated) inverse of the scale matrix of |
grid |
The grid of values on which to estimate the density generator. |
h |
The bandwidth of the kernel. |
Kernel |
The kernel used for the smoothing (default = "epanechnikov"). |
a |
The tuning parameter to improve the performance at |
shrink |
The shrinkage function to further improve the performance at |
mpfr |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
precBits |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
dopb |
See the “EllDistrEst.R” function of the R package ‘ElliptCopulas’. |
normalize |
A value in |
The context is the one of a -dimensional random vector
following an elliptical distribution with
generator
and scale matrix
such that the density of
is given by
for . Suppose that a sample
from
is given, and let
be an estimator for the scale matrix
. Then, when defining
for ,
this function computes the estimator
for
given by
where , with
the kernel and
the bandwidth.
The function
with a tuning parameter was introduced by Liebscher (2005), and the shrinkage function
yields further estimation improvement. We suggest to take (for
)
where is another tuning parameter. When
, one can just take
, and the value of
does not matter.
The estimator without the shrinkage function is implemented in the R package ‘ElliptCopulas’.
We use this implementation and bring in the shrinkage function.
In order to make identifiable, an extra normalization procedure is implemented
in line with an extra constraint on
.
When normalize = 1, this corresponds to
being the correlation matrix of
.
When normalize = 2, this corresponds to the identifiability condition of Derumigny & Fermanian (2022).
The estimates for at the grid points.
Derumigny, A., Fermanian, J.-D., Ryan, V., van der Spek, R. (2024). ElliptCopulas, R package version 0.1.4.1. url: https://CRAN.R-project.org/package=ElliptCopulas.
Derumigny, A. & Fermanian, J.-D. (2022).
Identifiability and estimation of meta-elliptical copula generators.
Journal of Multivariate Analysis 190:104962.
doi: https://doi.org/10.1016/j.jmva.2022.104962.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
Liebscher, E. (2005). A semiparametric density estimator based on elliptical distributions. Journal of Multivariate Analysis 92(1):205-225. doi: https://doi.org/10.1016/j.jmva.2003.09.007.
ellcopest
for improved kernel estimation of the elliptical generator of a meta-elliptical copula,
elliptselect
for selecting optimal tuning parameters for the improved kernel estimator of the elliptical generator,
phiellip
for estimating the -dependence between
random vectors having a meta-elliptical copula.
q = 4 # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Shrinkage function shrinkage = function(t,p){1-(1/((t^p) + 1))} # Tuning parameter selection opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters a = opt_parameters$Opta ; p = opt_parameters$Optp ; h = opt_parameters$Opth # Estimated elliptical generator g_est = elldistrest(Z = sample, Sigma_m1 = diag(q), grid = grid, h = h, a = a, shrink = function(t){shrinkage(t,p)}) plot(grid,g_est,type = "l", xlim = c(0,8)) lines(grid,g_q,col = "green")
q = 4 # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Shrinkage function shrinkage = function(t,p){1-(1/((t^p) + 1))} # Tuning parameter selection opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters a = opt_parameters$Opta ; p = opt_parameters$Optp ; h = opt_parameters$Opth # Estimated elliptical generator g_est = elldistrest(Z = sample, Sigma_m1 = diag(q), grid = grid, h = h, a = a, shrink = function(t){shrinkage(t,p)}) plot(grid,g_est,type = "l", xlim = c(0,8)) lines(grid,g_q,col = "green")
This functions selects optimal tuning parameters for improved kernel estimation of the generator of an elliptical distribution.
elliptselect(n, q, pseq, aseq)
elliptselect(n, q, pseq, aseq)
n |
The sample size. |
q |
The total dimension. |
pseq |
Candidate values for the |
aseq |
Candidate values for the |
When using the function elldistrest
for estimating an elliptical generator
based on a kernel
with bandwidth
, the function
and the shrinkage function (for )
this function selects and
in the following way.
Use the normal generator as reference generator, and define
as well as
When , take
(there is no need for shrinkage), and take
. The value of
does not matter.
When , specify a grid of candidate
-values in
and a grid of
-values in
.
For each of these candidate values, compute the corresponding optimal (AMISE) bandwidth
.
Take the combination of parameters that minimizes (a numerical approximation of) the (normal reference) AMISE given in equation (20) of De Keyser & Gijbels (2024).
A list with elements "Opta" containing the optimal , "Optp" containing the optimal
, and "Opth" containing the optimal
.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
elldistrest
for improved kernel estimation of the elliptical generator of an elliptical distribution,
ellcopest
for improved kernel estimation of the elliptical generator of a meta-elliptical copula,
phiellip
for estimating the -dependence between
random vectors having a meta-elliptical copula.
q = 4 n = 1000 opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200))
q = 4 n = 1000 opt_parameters = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200))
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function estimates the
-dependence between
by estimating the joint and marginal
copula densities.
estphi(sample, dim, est_method, phi)
estphi(sample, dim, est_method, phi)
sample |
A sample from a |
dim |
The vector of dimensions |
est_method |
The method used for estimating the |
phi |
The function |
When has copula density
with marginal copula densities
of
for
,
the
-dependence between
equals
for a certain continuous, convex function , and with
.
This functions allows to estimate in several ways (options for est_method)
list("hac", type = type, M = M) for parametric estimation by fitting a hierarchical Archimedean copula (hac) via pseudo-maximum likelihood estimation,
using a generator of type = type and a simulated Monte Carlo sample of size in order to approximate the expectation, see also the functions
mlehac
and phihac
,
list("nphac", estimator = estimator, type = type) for fully non-parametric estimation using the beta kernel estimator
or Gaussian transformation kernel estimator using a fitted hac (via pseudo-maximum likelihood estimation) of type = type to find locally optimal bandwidths, see also the function phinp
,
list("np", estimator = estimator, bw_method = bw_method) for fully non-parametric estimation using the beta kernel estimator or
Gaussian transformation kernel estimator, see phinp
for different bw_method arguments (either 1 or 2, for performing local bandwidth selection),
list("ellip", grid = grid) for semi-parametric estimation through meta-elliptical copulas, with bandwidths determined by the elliptselect
function,
see also the function phiellip
.
The estimated -dependence between
.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
phihac
for computing the -dependence between all the child copulas of a hac object with two nesting levels,
phinp
for fully non-parametric estimation of the -dependence between
random vectors,
phiellip
for estimating the -dependence between
random vectors having a meta-elliptical copula.
# Hierarchical Archimedean copula setting q = 4 dim = c(2,2) # Sample size n = 1000 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) hac = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,hac)) # Several estimators for the mutual information between two random vectors of size 2 est_phi_1 = estphi(sample,dim,list("hac",type = 1,M = 10000),function(t){t * log(t)}) est_phi_2 = estphi(sample,dim,list("nphac",estimator = "beta",type = 1), function(t){t * log(t)}) est_phi_3 = estphi(sample,dim,list("nphac",estimator = "trans",type = 1), function(t){t * log(t)}) est_phi_4 = estphi(sample,dim,list("np",estimator = "beta",bw_method = 1), function(t){t * log(t)}) est_phi_5 = estphi(sample,dim,list("np",estimator = "trans",bw_method = 1), function(t){t * log(t)}) est_phi_6 = estphi(sample,dim,list("np",estimator = "beta",bw_method = 2), function(t){t * log(t)}) est_phi_7 = estphi(sample,dim,list("np",estimator = "trans",bw_method = 2), function(t){t * log(t)}) true_phi = phihac(hac,dim,10000,function(t){t * log(t)}) # Gaussian copula setting q = 4 dim = c(2,2) # Sample size n = 1000 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from 4-dimensional normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # Estimate mutual information via MECIP procedure est_phi = estphi(sample,dim,list("ellip",grid = seq(0.005,100,by = 0.005)), function(t){t * log(t)}) true_phi = minormal(R,dim)
# Hierarchical Archimedean copula setting q = 4 dim = c(2,2) # Sample size n = 1000 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) hac = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,hac)) # Several estimators for the mutual information between two random vectors of size 2 est_phi_1 = estphi(sample,dim,list("hac",type = 1,M = 10000),function(t){t * log(t)}) est_phi_2 = estphi(sample,dim,list("nphac",estimator = "beta",type = 1), function(t){t * log(t)}) est_phi_3 = estphi(sample,dim,list("nphac",estimator = "trans",type = 1), function(t){t * log(t)}) est_phi_4 = estphi(sample,dim,list("np",estimator = "beta",bw_method = 1), function(t){t * log(t)}) est_phi_5 = estphi(sample,dim,list("np",estimator = "trans",bw_method = 1), function(t){t * log(t)}) est_phi_6 = estphi(sample,dim,list("np",estimator = "beta",bw_method = 2), function(t){t * log(t)}) est_phi_7 = estphi(sample,dim,list("np",estimator = "trans",bw_method = 2), function(t){t * log(t)}) true_phi = phihac(hac,dim,10000,function(t){t * log(t)}) # Gaussian copula setting q = 4 dim = c(2,2) # Sample size n = 1000 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from 4-dimensional normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # Estimate mutual information via MECIP procedure est_phi = estphi(sample,dim,list("ellip",grid = seq(0.005,100,by = 0.005)), function(t){t * log(t)}) true_phi = minormal(R,dim)
This function computes the sample -scores rank correlation matrix.
A ridge penalization is possible.
estR( sample, omega = 1, Q = function(t) { stats::qnorm(t) } )
estR( sample, omega = 1, Q = function(t) { stats::qnorm(t) } )
sample |
A sample from a |
omega |
The penalty parameter for ridge penalization (default = 1, meaning no penalization). |
Q |
The quantile function to be applied to the copula pseudo-observations (default = qnorm()). |
Given a -dimensional random vector
with
a
dimensional random vector, i.e.,
, the sample
-scores rank correlation matrix is given as
for ,
, and
, based on the observed
-scores
for , where
is the empirical cdf of the sample
for
and
.
The underlying assumption is that the copula of
is meta-elliptical.
The default for
is the standard normal quantile function (corresponding to the assumption of a Gaussian copula).
Ridge penalization (especially in the Gaussian copula setting) with penalty parameter omega =
boils down to computing
where stands for the identity matrix.
The (ridge penalized) sample -scores rank correlation matrix.
De Keyser, S. & Gijbels, I. (2024). Some new tests for independence among continuous random vectors.
Warton, D.I. (2008).
Penalized normal likelihood and ridge regularization of correlation and covariance matrices.
Journal of the American Statistical Association 103(481):340-349.
doi: https://doi.org/10.1198/016214508000000021.
cvomega
for selecting omega using K-fold cross-validation in case of a Gaussian copula.
# Multivariate normal copula setting q = 10 n = 50 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # 5-fold cross-validation with Gaussian likelihood as loss for selecting omega omega = cvomega(sample = sample,omegas = seq(0.01,0.999,len = 50),K = 5) R_est = estR(sample,omega = omega) # Multivariate Student-t copula setting q = 10 n = 500 # Degrees of freedom nu = 7 # Density of R^2, with R the radius of the elliptical distribution # Identifiability contraint is that R is the correlation matrix R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2)) * gamma(nu/2) * gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Univariate quantile function, with unit variance Q = function(t){extraDistr::qlst(t,nu,0,sqrt((nu-2)/nu))} # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate Student-t distribution # with correlation matrix R and nu degrees of freedom sample = ElliptCopulas::EllDistrSim(n,q,t(chol(R)),density_R2 = function(t){R2(t,q)}) R_est = estR(sample,Q = Q)
# Multivariate normal copula setting q = 10 n = 50 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R,method = "chol") # 5-fold cross-validation with Gaussian likelihood as loss for selecting omega omega = cvomega(sample = sample,omegas = seq(0.01,0.999,len = 50),K = 5) R_est = estR(sample,omega = omega) # Multivariate Student-t copula setting q = 10 n = 500 # Degrees of freedom nu = 7 # Density of R^2, with R the radius of the elliptical distribution # Identifiability contraint is that R is the correlation matrix R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2)) * gamma(nu/2) * gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Univariate quantile function, with unit variance Q = function(t){extraDistr::qlst(t,nu,0,sqrt((nu-2)/nu))} # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sample from multivariate Student-t distribution # with correlation matrix R and nu degrees of freedom sample = ElliptCopulas::EllDistrSim(n,q,t(chol(R)),density_R2 = function(t){R2(t,q)}) R_est = estR(sample,Q = Q)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function construct a hac object (hierarchical Archimedean copula) with two nesting levels given
the specified dimensions and parameters of the root and
child copulas.
gethac(dim, thetas, type)
gethac(dim, thetas, type)
dim |
The vector of dimensions |
thetas |
The parameters |
type |
The type of Archimedean copula. |
A hierarchical (or nested) Archimedean copula with two nesting levels and
child copulas is given by
where with
for
.
The (
-dimensional) copula
is called the root copula, and the (
-dimensional) copulas
are the child copulas.
They all belong to the class of Archimedean copulas, and we denote for the parameter of
for
.
A sufficient condition to guarantee that
indeed is a copula, is that
are all a particular member of this class of Archimedean copulas (e.g., Clayton),
and such that
for
(sufficient nesting condition).
When a certain child copula is one dimensional (
is one dimensional),
can be any number.
It must hold that length(thetas)
.
Many functions for working with nested Archimedean copulas are developed in the R package ‘HAC’,
and the function gethac
utilizes these functions to quickly construct a hac object that is useful for modelling
the dependence between .
See also the R package ‘HAC’ for the different possibilities of type (specified by a number in
).
A hac object with two nesting levels and child copulas.
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
Okhrin, O., Ristig, A. & Chen, G. (2024).
HAC: estimation, simulation and visualization of hierarchical Archimedean copulae (HAC), R package version 1.1-1.
url: https://CRAN.R-project.org/package=HAC.
phihac
for computing the -dependence between all the child copulas of a hac object with two nesting levels,
Helhac
for computing the Hellinger distance between all the child copulas of a hac object with two nesting levels,
mlehac
for maximum pseudo-likelihood estimation of the parameters of a hac object with two nesting levels.
dim = c(3,5,1,2) thetas = c(2,2,3,1,4) # 11 dimensional nested Gumbel copula with # (theta_0,theta_1,theta_2,theta_3,theta_4) = (2,2,3,1,4), # where the value of theta_3 could be anything, # because the third random vector is one dimensional HAC = gethac(dim,thetas,type = 1)
dim = c(3,5,1,2) thetas = c(2,2,3,1,4) # 11 dimensional nested Gumbel copula with # (theta_0,theta_1,theta_2,theta_3,theta_4) = (2,2,3,1,4), # where the value of theta_3 could be anything, # because the third random vector is one dimensional HAC = gethac(dim,thetas,type = 1)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the empirical penalized Gaussian copula covariance matrix with the Gaussian log-likelihood
plus the grouped lasso penalty as objective function, where the groups are the diagonal and off-diagonal blocks corresponding to the different
random vectors.
Model selection is done by choosing omega such that BIC is maximal.
grouplasso(Sigma, S, n, omegas, dim, step.size = 100, trace = 0)
grouplasso(Sigma, S, n, omegas, dim, step.size = 100, trace = 0)
Sigma |
An initial guess for the covariance matrix (typically equal to S). |
S |
The sample matrix of normal scores covariances. |
n |
The sample size. |
omegas |
The candidate values for the tuning parameter in |
dim |
The vector of dimensions |
step.size |
The step size used in the generalized gradient descent, affects the speed of the algorithm (default = 100). |
trace |
Controls how verbose output should be (default = 0, meaning no verbose output). |
Given a covariance matrix
the aim is to solve/compute
where the penalty function is of group lasso-type:
for a certain penalty function with penalty parameter
, and
a matrix with ones as off-diagonal elements and zeroes
on the diagonal (in order to avoid shrinking the variances, the operator
stands for elementwise multiplication).
For now, the only possibility in this function for is the lasso penalty
.
For other penalties (e.g., scad), one can do a local linear approximation to the penalty function and iteratively perform weighted group lasso optimizations (similar to what is done in the function
covgpenal
).
Regarding the implementation, we used the code available in the R package ‘spcov’ (see the manual for further explanations), but altered it to the context of a group-lasso penalty.
For tuning , we maximize (over a grid of candidate values) the BIC criterion
where is the estimated candidate covariance matrix using
and df (degrees of freedom) equals
with the
'th block of
, similarly for
.
A list with elements "est" containing the (group lasso) penalized matrix of sample normal scores rank correlations (output as provided by the function “spcov.R”), and "omega" containing the optimal tuning parameter.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
Bien, J. & Tibshirani, R. (2022). spcov: sparse estimation of a covariance matrix, R package version 1.3. url: https://CRAN.R-project.org/package=spcov.
Bien, J. & Tibshirani, R. (2011). Sparse Estimation of a Covariance Matrix. Biometrika 98(4):807-820. doi: https://doi.org/10.1093/biomet/asr054.
covgpenal
for (elementwise) lasso-type estimation of the normal scores rank correlation matrix.
q = 10 dim = c(5,5) n = 100 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sparsity on off-diagonal blocks R0 = createR0(R,dim) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R0,method = "chol") # Normal scores scores = matrix(0,n,q) for(j in 1:q){scores[,j] = qnorm((n/(n+1)) * ecdf(sample[,j])(sample[,j]))} # Sample matrix of normal scores covariances Sigma_est = cov(scores) * ((n-1)/n) # Candidate tuning parameters omega = seq(0.01, 0.6, length = 50) Sigma_est_penal = grouplasso(Sigma_est, Sigma_est, n, omega, dim)
q = 10 dim = c(5,5) n = 100 # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Sparsity on off-diagonal blocks R0 = createR0(R,dim) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),R0,method = "chol") # Normal scores scores = matrix(0,n,q) for(j in 1:q){scores[,j] = qnorm((n/(n+1)) * ecdf(sample[,j])(sample[,j]))} # Sample matrix of normal scores covariances Sigma_est = cov(scores) * ((n-1)/n) # Candidate tuning parameters omega = seq(0.01, 0.6, length = 50) Sigma_est_penal = grouplasso(Sigma_est, Sigma_est, n, omega, dim)
This function performs local bandwidth selection based on the amse (asymptotic mean squared error) for the beta kernel or Gaussian transformation kernel copula density estimator.
hamse(input, cop = NULL, pseudos = NULL, n, estimator, bw_method)
hamse(input, cop = NULL, pseudos = NULL, n, estimator, bw_method)
input |
The copula argument at which the optimal local bandwidth is to be computed. |
cop |
A fitted reference hac object, in case bw_method = 0 (default = NULL). |
pseudos |
The (estimated) copula observations from a |
n |
The sample size. |
estimator |
Either "beta" or "trans" for the beta kernel or the Gaussian transformation kernel copula density estimator. |
bw_method |
A number in |
When estimator = "beta", this function computes, at a certain input, a numerical approximation of the optimal local bandwidth (for the beta kernel copula density estimator) in terms of the amse (asymptotic mean squared error) given in equation (27) of De Keyser & Gijbels (2024). When estimator = "trans" (for the Gaussian transformation kernel copula density estimator), this optimal bandwidth is given at the end of Section 5.2 in De Keyser & Gijbels (2024).
Of course, these optimal bandwidths depend upon the true unknown copula.
If bw_method = 0, then the given fitted (e.g., via MLE using mlehac
) hac object (hierarchical Archimedean copula) cop is used as reference copula.
If bw_method = 1, then a non-parametric (beta or Gaussian transformation) kernel copula density estimator based on the pseudos as pivot is used. This pivot is computed
using the big O bandwidth (i.e., in case of the beta estimator, and
for the transformation estimator, with
the total dimension).
The optimal local bandwidth (in terms of amse).
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
betakernelestimator
for the computation of the beta kernel copula density estimator, transformationestimator
for the computation of the Gaussian transformation kernel copula density estimator,
phinp
for fully non-parametric estimation of the -dependence between
random vectors.
q = 4 dim = c(2,2) # Sample size n = 1000 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Maximum pseudo-likelihood estimator to be used # as reference copula for bw_method = 0 est_cop = mlehac(sample,dim,1,c(2,3,4)) h_1 = hamse(rep(0.5,q),cop = est_cop,n = n,estimator = "beta",bw_method = 0) h_2 = hamse(rep(0.5,q),cop = est_cop,n = n,estimator = "trans",bw_method = 0) h_3 = hamse(rep(0.5,q),pseudos = pseudos,n = n,estimator = "beta",bw_method = 1) h_4 = hamse(rep(0.5,q),pseudos = pseudos,n = n,estimator = "trans",bw_method = 1) est_dens_1 = betakernelestimator(rep(0.5,q),h_1,pseudos) est_dens_2 = transformationestimator(rep(0.5,q),h_2,pseudos) est_dens_3 = betakernelestimator(rep(0.5,q),h_3,pseudos) est_dens_4 = transformationestimator(rep(0.5,q),h_4,pseudos) true = HAC::dHAC(c("X1" = 0.5, "X2" = 0.5, "X3" = 0.5, "X4" = 0.5), HAC)
q = 4 dim = c(2,2) # Sample size n = 1000 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Maximum pseudo-likelihood estimator to be used # as reference copula for bw_method = 0 est_cop = mlehac(sample,dim,1,c(2,3,4)) h_1 = hamse(rep(0.5,q),cop = est_cop,n = n,estimator = "beta",bw_method = 0) h_2 = hamse(rep(0.5,q),cop = est_cop,n = n,estimator = "trans",bw_method = 0) h_3 = hamse(rep(0.5,q),pseudos = pseudos,n = n,estimator = "beta",bw_method = 1) h_4 = hamse(rep(0.5,q),pseudos = pseudos,n = n,estimator = "trans",bw_method = 1) est_dens_1 = betakernelestimator(rep(0.5,q),h_1,pseudos) est_dens_2 = transformationestimator(rep(0.5,q),h_2,pseudos) est_dens_3 = betakernelestimator(rep(0.5,q),h_3,pseudos) est_dens_4 = transformationestimator(rep(0.5,q),h_4,pseudos) true = HAC::dHAC(c("X1" = 0.5, "X2" = 0.5, "X3" = 0.5, "X4" = 0.5), HAC)
This function computes the Hellinger distance between all the child copulas of a hac object obtained by the function gethac
, i.e.,
given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
where
are connected via a hierarchical Archimedean copula with two nesting levels,
Helhac
computes the Hellinger distance
between .
Helhac(cop, dim, M)
Helhac(cop, dim, M)
cop |
A hac object as provided by the function |
dim |
The vector of dimensions |
M |
The size of the Monte Carlo sample used for approximating the integral of the Hellinger distance. |
When has copula density
with marginal copula densities
of
for
,
the
-dependence between
equals
for a certain continuous, convex function .
The Hellinger distance corresponds to
, and
could be approximated by
as implemented in the function
phihac
.
Yet, for this specific choice of , it is better to first simplify
to
and then, by drawing a sample of size from
, say
, with
, approximate it by
The function Helhac
computes when
is a hierarchical Archimedean copula with two nesting levels,
as produced by the function
gethac
.
The Hellinger distance between (i.e., between all the child copulas of the hac object).
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
gethac
for creating a hac object with two nesting levels,
phihac
for computing the -dependence between all the child copulas of a hac object with two nesting levels,
mlehac
for maximum pseudo-likelihood estimation of the parameters of a hac object with two nesting levels.
dim = c(2,2) thetas = c(2,3,4) # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Hellinger distance based on Monte Carlo sample of size 10000 Hel = Helhac(HAC,dim,10000)
dim = c(2,2) thetas = c(2,3,4) # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Hellinger distance based on Monte Carlo sample of size 10000 Hel = Helhac(HAC,dim,10000)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the correlation-based Hellinger distance between
given the entire correlation matrix
.
Helnormal(R, dim)
Helnormal(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
Given a correlation matrix
the Hellinger distance equals
where denotes the identity matrix, and
is the correlation matrix under independence of
.
The underlying assumption is that the copula of
is Gaussian.
The correlation-based Hellinger distance between .
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
minormal
for the computation of the Gaussian copula mutual information,
Helnormalavar
for the computation of the asymptotic variance of the plug-in estimator for the Gaussian copula Hellinger distance.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) Helnormal(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) Helnormal(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the asymptotic variance of the plug-in estimator for the correlation-based Hellinger distance
between
given the entire correlation matrix
.
Helnormalavar(R, dim)
Helnormalavar(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
The asymptotic variance of the plug-in estimator is computed at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
The asymptotic variance of the correlation-based Hellinger distance between .
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
minormal
for the computation of the mutual information,
Helnormal
for the computation of the Hellinger distance,
minormalavar
for the computation of the asymptotic variance of the plug-in estimator for the mutual information,
estR
for the computation of the sample matrix of normal scores rank correlations.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) Helnormalavar(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) Helnormalavar(R,dim)
This function clusters the columns (variables) of a dataset via agglomerative hierarchical variable clustering using estimated multivariate similarities (dependence coefficients) between random vectors.
Icluster( data, est_method, max_dim = Inf, norm = NULL, link = "average", trace = 1 )
Icluster( data, est_method, max_dim = Inf, norm = NULL, link = "average", trace = 1 )
data |
The dataset ( |
est_method |
The method for estimating the similarity between two clusters of variables. |
max_dim |
The maximum dimension of the random vectors for which no link function is used when computing the similarity (default = Inf). |
norm |
A possible normalization function applied to the dependence measure (default = NULL, meaning no normalization). |
link |
The link function to be used when max_dim is exceeded (default = "average"). |
trace |
Controls how verbose output should be (default = 1, showing the progress). |
Suppose that the variables (of which we have
observations in data) are
.
Then, most important in hierarchical variable clustering, is computing the similarity
between two disjoint subsets of variables .
In particular, the main algorithm is as follows:
Each object forms a separate cluster, i.e.,
is the initial feature partition.
For :
For each pair of disjoint clusters , compute the similarity
.
Define , where
are the clusters having maximal similarity according to the previous step.
The algorithm stops with .
We call the hierarchy constructed throughout the algorithm, and define, for
,
, with
and , with
Adiam stands for the average diameter of a partition (measuring the homogeneity, which we want to be large), while Msplit stands for the maximum split of a partition (measuring the non-separation, which we want to be small).
For measuring the similarity , we approach
and
as being two random vectors
(let's say of dimensions
and
respectively). For
, we take an estimated dependence measure between (two) random vectors. The following options are possible:
list("phi", "mi", "Gauss", omegas = omegas) for the estimated Gaussian copula mutual information. Use omegas = 1 for no penalty, or a sequence of omegas for a ridge penalty tuned via 5-fold cross-validation,
see also the functions minormal
, estR
, and cvomega
,
list("phi", "Hel", "Gauss", omegas = omegas) for the estimated Gaussian copula Hellinger distance. Use omegas = 1 for no penalty, or a sequence of omegas for a ridge penalty tuned via 5-fold cross-validation,
see also the functions Helnormal
, estR
, and cvomega
,
list("phi", phi(t), "hac", type = type, M = M) for general -dependence with specified function phi(t) =
,
estimated by fitting (via pseudo maximum likelihood estimation) a hierarchical Archimedean copula of given type = type,
and computed based on a Monte Carlo sample of size
in order to approximate the expectation, see also the functions
mlehac
, phihac
and estphi
,
list("phi", phi(t), "nphac", estimator = estimator, type = type) for general
-dependence with specified function phi(t) =
,
estimated via non-parametric beta kernel estimation or Gaussian transformation kernel estimation,
and local bandwidth selection, by using a fitted (via pseudo maximum likelihood) hierarchical Archimedean copula
as reference copula, see also the functions
phinp
and estphi
,
list("phi", phi(t), "np", estimator = estimator, bw_method = bw_method) for general -dependence with specified function phi(t) =
,
estimated via non-parametric beta kernel estimation or Gaussian transformation kernel estimation,
and local bandwidth selection, either by using a non-parametric kernel estimator as reference copula if bw_method = 1,
or by using a big O bandwidth rule if bw_method = 2, see also the functions
phinp
and estphi
,
list("phi", phi(t), "ellip", grid = grid) for general -dependence with specified function phi(t) =
,
estimated via the improved MECIP procedure on the specified grid, and parameter selection done via
the function
elliptselect
using the Gaussian generator as reference generator, see also the functions phiellip
and estphi
,
list("ot", coef = coef, omegas = omegas) for Gaussian copula Bures-Wasserstein dependence measures, either coefficient (coef = 1) or coefficient
(coef = 2).
Use omegas = 1 for no penalty, or a sequence of omegas for a ridge penalty tuned via 5-fold cross-validation,
see also the functions
bwd1
, bwd2
, estR
, and cvomega
.
When max_dim, the specified link function (say
) is used
for computing the similarity between
and
, i.e.,
which by default is the average of all inter-pairwise similarities. Other options are "single" for the minimum, and "complete" for the maximum.
The function norm (say ) is a possible normalization applied to the similarity measure, i.e., instead of
computing
(using the method specified by est_method), the similarity becomes
.
The default is
, meaning that no normalization is applied.
A list with elements "hierarchy" containing the hierarchy constructed throughout the algorithm (a hash object), "all" containing all similarities that were computed throughout the algorithm (a hash object), "diam" containing the average diameters of all partitions created throughout the algorithm (a vector), and "split" containing the maximum splits of all partitions created throughout the algorithm (a vector).
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
De Keyser, S. & Gijbels, I. (2024). High-dimensional copula-based Wasserstein dependence. doi: https://doi.org/10.48550/arXiv.2404.07141.
minormal
for the computation of the Gaussian copula mutual information,
Helnormal
for the computation of the Gaussian copula Hellinger distance,
estphi
for several approach to estimating the -dependence between
random vectors,
bwd1
for the computation of the first Bures-Wasserstein dependence coefficient ,
bwd2
for the computation of the second Bures-Wasserstein dependence coefficient .
q = 20 # We will impose a clustering # {{X1,X2},{X3,X4,X5},{X6,X7,X8},{X9,X10,X11,X12,X13},{X14,X15,X16,X17,X18,X19,X20}} dim = c(2,3,3,5,7) # Sample size n = 200 # Twenty dimensional hierarchical Gumbel copula with parameters # (theta_0,theta_1,theta_2,theta_3,theta_4,theta_5) = (2,3,4,5,6,7) hac = gethac(dim,c(2,3,4,5,6,7),type = 1) # So, strongest cluster is {X14,X15,X16,X17,X18,X19,X20}, then {X9,X10,X11,X12,X13}, # then {X6,X7,X8}, then {X3,X4,X5}, and finally {X1,X2} # Sample sample = suppressWarnings(HAC::rHAC(n,hac)) # Cluster using different methods # Gaussian copula based methods Clustering1 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = 1)) # 5-cluster partition Clustering1$hierarchy$Aleph_16 Clustering2 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = seq(0.01,0.999,len = 50))) # 5-cluster partition Clustering2$hierarchy$Aleph_16 Clustering3 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = 1), max_dim = 2) # 5-cluster partition Clustering3$hierarchy$Aleph_16 Clustering4 = Icluster(data = sample, est_method = list("phi", "Hel", "Gauss", omegas = 1)) # 5-cluster partition Clustering4$hierarchy$Aleph_16 Clustering5 = Icluster(data = sample, est_method = list("ot", coef = 1, omegas = 1)) # 5-cluster partition Clustering5$hierarchy$Aleph_16 Clustering6 = Icluster(data = sample, est_method = list("ot", coef = 2, omegas = 1)) # 5-cluster partition Clustering6$hierarchy$Aleph_16 Clustering7 = Icluster(data = sample, est_method = list("ot", coef = 2, omegas = 1), max_dim = 4) # 5-cluster partition Clustering7$hierarchy$Aleph_16 # Parametric hierarchical Archimedean copula approach Clustering8 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "hac", type = 1, M = 1000), max_dim = 4) # 5-cluster partition Clustering8$hierarchy$Aleph_16 Clustering9 = Icluster(data = sample, est_method = list("phi", function(t){(sqrt(t)-1)^2}, "hac", type = 1, M = 1000), max_dim = 2) # 5-cluster partition Clustering9$hierarchy$Aleph_16 # Non-parametric approaches Clustering10 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "nphac", estimator = "beta", type = 1), max_dim = 3) # 5-cluster partition Clustering10$hierarchy$Aleph_16 Clustering11 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "nphac", estimator = "trans", type = 1), max_dim = 3) # 5-cluster partition Clustering11$hierarchy$Aleph_16 Clustering12 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "np", estimator = "beta", bw_method = 1), max_dim = 3) # 5-cluster partition Clustering12$hierarchy$Aleph_16 Clustering13 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "np", estimator = "trans", bw_method = 2), max_dim = 3) # 5-cluster partition Clustering13$hierarchy$Aleph_16 Clustering14 = Icluster(data = sample, est_method = list("phi", function(t){(sqrt(t)-1)^2}, "np", estimator = "trans", bw_method = 1), max_dim = 2) # 5-cluster partition Clustering14$hierarchy$Aleph_16 # Semi-parametric meta-elliptical copula approach # Uncomment to run (takes a long time) # Clustering15 = Icluster(data = sample, # est_method = list("phi", function(t){t * log(t)}, "ellip", # grid = seq(0.005,100,by = 0.005)), max_dim = 2) # 5-cluster partition # Clustering15$hierarchy$Aleph_16
q = 20 # We will impose a clustering # {{X1,X2},{X3,X4,X5},{X6,X7,X8},{X9,X10,X11,X12,X13},{X14,X15,X16,X17,X18,X19,X20}} dim = c(2,3,3,5,7) # Sample size n = 200 # Twenty dimensional hierarchical Gumbel copula with parameters # (theta_0,theta_1,theta_2,theta_3,theta_4,theta_5) = (2,3,4,5,6,7) hac = gethac(dim,c(2,3,4,5,6,7),type = 1) # So, strongest cluster is {X14,X15,X16,X17,X18,X19,X20}, then {X9,X10,X11,X12,X13}, # then {X6,X7,X8}, then {X3,X4,X5}, and finally {X1,X2} # Sample sample = suppressWarnings(HAC::rHAC(n,hac)) # Cluster using different methods # Gaussian copula based methods Clustering1 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = 1)) # 5-cluster partition Clustering1$hierarchy$Aleph_16 Clustering2 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = seq(0.01,0.999,len = 50))) # 5-cluster partition Clustering2$hierarchy$Aleph_16 Clustering3 = Icluster(data = sample, est_method = list("phi", "mi", "Gauss", omegas = 1), max_dim = 2) # 5-cluster partition Clustering3$hierarchy$Aleph_16 Clustering4 = Icluster(data = sample, est_method = list("phi", "Hel", "Gauss", omegas = 1)) # 5-cluster partition Clustering4$hierarchy$Aleph_16 Clustering5 = Icluster(data = sample, est_method = list("ot", coef = 1, omegas = 1)) # 5-cluster partition Clustering5$hierarchy$Aleph_16 Clustering6 = Icluster(data = sample, est_method = list("ot", coef = 2, omegas = 1)) # 5-cluster partition Clustering6$hierarchy$Aleph_16 Clustering7 = Icluster(data = sample, est_method = list("ot", coef = 2, omegas = 1), max_dim = 4) # 5-cluster partition Clustering7$hierarchy$Aleph_16 # Parametric hierarchical Archimedean copula approach Clustering8 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "hac", type = 1, M = 1000), max_dim = 4) # 5-cluster partition Clustering8$hierarchy$Aleph_16 Clustering9 = Icluster(data = sample, est_method = list("phi", function(t){(sqrt(t)-1)^2}, "hac", type = 1, M = 1000), max_dim = 2) # 5-cluster partition Clustering9$hierarchy$Aleph_16 # Non-parametric approaches Clustering10 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "nphac", estimator = "beta", type = 1), max_dim = 3) # 5-cluster partition Clustering10$hierarchy$Aleph_16 Clustering11 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "nphac", estimator = "trans", type = 1), max_dim = 3) # 5-cluster partition Clustering11$hierarchy$Aleph_16 Clustering12 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "np", estimator = "beta", bw_method = 1), max_dim = 3) # 5-cluster partition Clustering12$hierarchy$Aleph_16 Clustering13 = Icluster(data = sample, est_method = list("phi", function(t){t * log(t)}, "np", estimator = "trans", bw_method = 2), max_dim = 3) # 5-cluster partition Clustering13$hierarchy$Aleph_16 Clustering14 = Icluster(data = sample, est_method = list("phi", function(t){(sqrt(t)-1)^2}, "np", estimator = "trans", bw_method = 1), max_dim = 2) # 5-cluster partition Clustering14$hierarchy$Aleph_16 # Semi-parametric meta-elliptical copula approach # Uncomment to run (takes a long time) # Clustering15 = Icluster(data = sample, # est_method = list("phi", function(t){t * log(t)}, "ellip", # grid = seq(0.005,100,by = 0.005)), max_dim = 2) # 5-cluster partition # Clustering15$hierarchy$Aleph_16
This function installs a python virtual environment.
install_tensorflow(envname = "r-tensorflow")
install_tensorflow(envname = "r-tensorflow")
envname |
Name of the environment. |
No return value, used for creating a python virtual environment.
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the correlation-based mutual information between
given the entire correlation matrix
.
minormal(R, dim)
minormal(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
Given a correlation matrix
the mutual information equals
The underlying assumption is that the copula of is Gaussian.
The correlation-based mutual information between .
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
Helnormal
for the computation of the Gaussian copula Hellinger distance,
minormalavar
for the computation of the asymptotic variance of the plug-in estimator for the Gaussian copula mutual information,
miStudent
for the computation of the Student-t mutual information.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) minormal(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) minormal(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the asymptotic variance of the plug-in estimator for the correlation-based mutual information
between
given the entire correlation matrix
.
minormalavar(R, dim)
minormalavar(R, dim)
R |
The correlation matrix of |
dim |
The vector of dimensions |
The asymptotic variance of the plug-in estimator is computed at
,
where
is the sample matrix of normal scores rank correlations.
The underlying assumption is that the copula of
is Gaussian.
The asymptotic variance of the correlation-based mutual information between .
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
minormal
for the computation of the mutual information,
Helnormal
for the computation of the Hellinger distance,
Helnormalavar
for the computation of the asymptotic variance of the plug-in estimator for the Hellinger distance,
estR
for the computation of the sample matrix of normal scores rank correlations.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) minormalavar(R,dim)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) minormalavar(R,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function computes the Student-t mutual information between
given the entire correlation matrix
and the degrees of freedom nu.
miStudent(R, dim, nu)
miStudent(R, dim, nu)
R |
The correlation matrix of |
dim |
The vector of dimensions |
nu |
The degrees of freedom. |
Given a correlation matrix
and a certain amount of degrees of freedom ,
the Student-t mutual information equals
where
with the gamma function and
the digamma function.
The underlying assumption is that the copula of
is Student-t.
The Student-t mutual information between .
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
minormal
for the computation of the Gaussian copula mutual information.
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Degrees of freedom nu = 7 miStudent(R,dim,nu)
q = 10 dim = c(1,2,3,4) # AR(1) correlation matrix with correlation 0.5 R = 0.5^(abs(matrix(1:q-1,nrow = q, ncol = q, byrow = TRUE) - (1:q-1))) # Degrees of freedom nu = 7 miStudent(R,dim,nu)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function performs maximum pseudo-likelihood estimation for the parameters of
a hierarchical Archimedean copula with two nesting levels of a specific type, used for modelling the dependence between
.
mlehac(sample, dim, type, start_val = NULL)
mlehac(sample, dim, type, start_val = NULL)
sample |
A sample from a |
dim |
The vector of dimensions |
type |
The type of Archimedean copula. |
start_val |
The starting values for the parameters |
Under the assumption that has a hierarchical Archimedean copula with two nesting levels, i.e.,
where with
for
,
and with
the parameter of
for
(see the function
gethac
), this functions performs maximum pseudo-likelihood estimation for
. This means that for
the (rescaled) empirical cdf of
based on a sample
for
and
(recall that
),
we look for
where is the copula density of the hierarchical Archimedean copula.
We assume that belongs to the same family of Archimedean copulas (e.g., Clayton) for
,
and make use of the R package ‘HAC’.
In case the starting values (start_val) are not specified, the starting value for is put equal to 1.9
and the starting values for
with
are determined by performing
maximum pseudo-likelihood estimation to the
-dimensional marginals with starting value
.
The maximum pseudo-likelihood estimates for .
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
Okhrin, O., Ristig, A. & Chen, G. (2024).
HAC: estimation, simulation and visualization of hierarchical Archimedean copulae (HAC), R package version 1.1-1.
url: https://CRAN.R-project.org/package=HAC.
gethac
for creating a hac object with two nesting levels,
phihac
for computing the -dependence between all the child copulas of a hac object with two nesting levels,
Helhac
for computing the Hellinger distance between all the child copulas of a hac object with two nesting levels.
dim = c(2,2) thetas = c(2,3,4) # Sample size n = 1000 # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Maximum pseudo-likelihood estimator with starting values equal to thetas HAC_est_1 = mlehac(sample,dim,1,thetas) # Maximum pseudo-likelihood estimator with starting values # theta_0 = 1.9, and theta_1, theta_2 determined by maximum # pseudo-likelihood estimation for marginal child copulas HAC_est_2 = mlehac(sample,dim,1)
dim = c(2,2) thetas = c(2,3,4) # Sample size n = 1000 # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Maximum pseudo-likelihood estimator with starting values equal to thetas HAC_est_1 = mlehac(sample,dim,1,thetas) # Maximum pseudo-likelihood estimator with starting values # theta_0 = 1.9, and theta_1, theta_2 determined by maximum # pseudo-likelihood estimation for marginal child copulas HAC_est_2 = mlehac(sample,dim,1)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function sorts the columns (variables) of a sample of
such that the dimensions are in ascending order.
otsort(sample, dim)
otsort(sample, dim)
sample |
A sample from a |
dim |
The vector of dimensions |
The columns of sample are rearranged such that the data corresponding to the random vector
having the smallest dimension
comes first, then the random vector with second smallest dimension, and so on.
A list with elements "sample" containing the ordered sample, and "dim" containing the ordered dimensions.
q = 10 n = 50 dim = c(2,3,1,4) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),diag(q), method = "chol") ordered = otsort(sample,dim)
q = 10 n = 50 dim = c(2,3,1,4) # Sample from multivariate normal distribution sample = mvtnorm::rmvnorm(n,rep(0,q),diag(q), method = "chol") ordered = otsort(sample,dim)
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function estimates the
-dependence between
by estimating the joint and marginal
meta-elliptical copula generators via the MECIP.
phiellip(sample, dim, phi, grid, params, normalize = 1)
phiellip(sample, dim, phi, grid, params, normalize = 1)
sample |
A sample from a |
dim |
The vector of dimensions |
phi |
The function |
grid |
The grid of values on which to estimate the density generators. |
params |
The tuning parameters to be used when estimating the density generators. |
normalize |
A value in |
When has a meta-elliptical copula with generator
, marginal generators
of
for
, and scale matrix
the -dependence between
equals
where (recall that for
)
and , with
the quantile function corresponding to
.
The expectation is replaced by the empirical mean using the estimated sample
with
for
, where
for .
Here,
will be the quantile function corresponding to the final estimator for
, and
is the (rescaled) empirical cdf of based on a sample
for
and
.
The estimation of is done via its relation with the Kendall's tau matrix, see the function “KTMatrixEst.R” in
the R package ‘ElliptCopulas’ of Derumigny et al. (2024).
For estimating and
for
, the function
ellcopest
is used.
This function requires certain tuning parameters (a bandwidth , a parameter
, and a parameter
for the shrinkage function). Suppose that there are
marginal random vectors (among
) that are of dimension strictly larger than one.
Then, all tuning parameters should be given as
i.e., will be used for estimating
, and
will be used for estimating
for
.
When for a certain
, the function “Convert_gd_To_g1.R” from the R package ‘ElliptCopulas’ is used to estimate
.
In order to make identifiable, an extra normalization procedure is implemented
in line with an extra constraint on
.
When normalize = 1, this corresponds to
being the correlation matrix of
.
When normalize = 2, this corresponds to the identifiability condition of Derumigny & Fermanian (2022).
The estimated -dependence between
.
Derumigny, A., Fermanian, J.-D., Ryan, V., van der Spek, R. (2024). ElliptCopulas, R package version 0.1.4.1. url: https://CRAN.R-project.org/package=ElliptCopulas.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
elldistrest
for improved kernel estimation of the elliptical generator of an elliptical distribution,
ellcopest
for improved kernel estimation of the elliptical generator of a meta-elliptical copula,
elliptselect
for selecting optimal tuning parameters for the improved kernel estimator of the elliptical generator.
q = 4 dim = c(2,2) # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Tuning parameter selection for g_R opt_parameters_joint = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters for g_R a = opt_parameters_joint$Opta ; p = opt_parameters_joint$Optp ; h = opt_parameters_joint$Opth # Tuning parameter selection for g_R_1 (same for g_R_2) opt_parameters_marg = elliptselect(n,2,seq((3/4)-(1/2)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters for g_R_1 (same for g_R_2) a1 = opt_parameters_marg$Opta ; p1 = opt_parameters_marg$Optp ; h1 = opt_parameters_marg$Opth a2 = a1 ; p2 = p1 ; h2 = h1 params = list("h" = c(h,h1,h2), "a" = c(a,a1,a2), "p" = c(p,p1,p2)) # Mutual information between two random vectors of size 2 est_phi = phiellip(sample, dim, function(t){t * log(t)}, grid, params)
q = 4 dim = c(2,2) # Sample size n = 1000 # Grid on which to evaluate the elliptical generator grid = seq(0.005,100,by = 0.005) # Degrees of freedom nu = 7 # Student-t generator with 7 degrees of freedom g_q = ((nu/(nu-2))^(q/2))*(gamma((q+nu)/2)/(((pi*nu)^(q/2))*gamma(nu/2))) * ((1+(grid/(nu-2)))^(-(q+nu)/2)) # Density of squared radius R2 = function(t,q){(gamma((q+nu)/2)/(((nu-2)^(q/2))*gamma(nu/2)*gamma(q/2))) * (t^((q/2)-1)) * ((1+(t/(nu-2)))^(-(q+nu)/2))} # Sample from 4-dimensional Student-t distribution with 7 degrees of freedom # and identity covariance matrix sample = ElliptCopulas::EllDistrSim(n,q,diag(q),density_R2 = function(t){R2(t,q)}) # Tuning parameter selection for g_R opt_parameters_joint = elliptselect(n,q,seq((3/4)-(1/q)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters for g_R a = opt_parameters_joint$Opta ; p = opt_parameters_joint$Optp ; h = opt_parameters_joint$Opth # Tuning parameter selection for g_R_1 (same for g_R_2) opt_parameters_marg = elliptselect(n,2,seq((3/4)-(1/2)+0.01,1-0.01,len = 200), seq(0.01,2,len = 200)) # Optimal tuning parameters for g_R_1 (same for g_R_2) a1 = opt_parameters_marg$Opta ; p1 = opt_parameters_marg$Optp ; h1 = opt_parameters_marg$Opth a2 = a1 ; p2 = p1 ; h2 = h1 params = list("h" = c(h,h1,h2), "a" = c(a,a1,a2), "p" = c(p,p1,p2)) # Mutual information between two random vectors of size 2 est_phi = phiellip(sample, dim, function(t){t * log(t)}, grid, params)
This function computes the -dependence between all the child copulas of a hac object obtained by the function
gethac
, i.e.,
given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
where
are connected via a hierarchical Archimedean copula with two nesting levels, phihac computes the
-dependence
between
.
phihac(cop, dim, M, phi)
phihac(cop, dim, M, phi)
cop |
A hac object as provided by the function |
dim |
The vector of dimensions |
M |
The size of the Monte Carlo sample used for approximating the integral of the |
phi |
The function |
When has copula density
with marginal copula densities
of
for
,
the
-dependence between
equals
for a certain continuous, convex function .
By drawing a sample of size
from
, say
, with
, we can approximate
by
The function phihac
computes when
is a hierarchical Archimedean copula with two nesting levels,
as produced by the function
gethac
.
The -dependence between
(i.e., between all the child copulas of the hac object).
De Keyser, S. & Gijbels, I. (2024).
Parametric dependence between random vectors via copula-based divergence measures.
Journal of Multivariate Analysis 203:105336.
doi: https://doi.org/10.1016/j.jmva.2024.105336.
gethac
for creating a hac object with two nesting levels,
Helhac
for computing the Hellinger distance between all the child copulas of a hac object with two nesting levels,
mlehac
for maximum pseudo-likelihood estimation of the parameters of a hac object with two nesting levels.
dim = c(2,2) thetas = c(2,3,4) # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Mutual information based on Monte Carlo sample of size 10000 Phi_dep = phihac(HAC,dim,10000,function(t){t * log(t)})
dim = c(2,2) thetas = c(2,3,4) # 4 dimensional nested Gumbel copula with (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,thetas,type = 1) # Mutual information based on Monte Carlo sample of size 10000 Phi_dep = phihac(HAC,dim,10000,function(t){t * log(t)})
Given a -dimensional random vector
with
a
-dimensional random vector, i.e.,
,
this function estimates the
-dependence between
by estimating the joint and marginal
copula densities via fully non-parametric copula kernel density estimation.
phinp(sample, cop = NULL, dim, phi, estimator, bw_method)
phinp(sample, cop = NULL, dim, phi, estimator, bw_method)
sample |
A sample from a |
cop |
A fitted reference hac object, in case bw_method = 0 (default = NULL). |
dim |
The vector of dimensions |
phi |
The function |
estimator |
Either "beta" or "trans" for the beta kernel or the Gaussian transformation kernel copula density estimator. |
bw_method |
A number in |
When has copula density
with marginal copula densities
of
for
,
the
-dependence between
equals
for a certain continuous, convex function , and with
.
The expectation is replaced by the empirical mean using the estimated copula sample
with
for
, where (recall that
for
)
Hereby, is the (rescaled) empirical cdf of
based on a sample
for
and
.
The joint copula density and marginal copula densities
for
are estimated via fully non-parametric copula kernel density estimation.
When estimator = "beta", the beta kernel copula density estimator is used.
When estimator = "trans", the Gaussian transformation kernel copula density estimator is used.
Bandwidth selection is done locally by using the function hamse
.
When bw_method = 0, then the given fitted (e.g., via MLE using mlehac
) hac object (hierarchical Archimedean copula) cop is used as reference copula.
When bw_method = 1, then a non-parametric (beta or Gaussian transformation) kernel copula density estimator based on the pseudos as pivot is used. This pivot is computed
using the big O bandwidth (i.e., in case of the beta estimator, and
for the transformation estimator, with
the total dimension).
When bw_method = 2, the big O bandwidths are taken.
The estimated -dependence between
.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
betakernelestimator
for the computation of the beta kernel copula density estimator, transformationestimator
for the computation of the Gaussian transformation kernel copula density estimator,
hamse
for local bandwidth selection for the beta kernel or Gaussian transformation kernel copula density estimator.
q = 4 dim = c(2,2) # Sample size n = 500 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Maximum pseudo-likelihood estimator to be used as reference copula for bw_method = 0 est_cop = mlehac(sample,dim,1,c(2,3,4)) # Estimate mutual information between two random vectors of size 2 in different ways est_phi_1 = phinp(sample,cop = est_cop,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 0) est_phi_2 = phinp(sample,cop = est_cop,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 0) est_phi_3 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 1) est_phi_4 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 1) est_phi_5 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 2) est_phi_6 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 2)
q = 4 dim = c(2,2) # Sample size n = 500 # Four dimensional hierarchical Gumbel copula # with parameters (theta_0,theta_1,theta_2) = (2,3,4) HAC = gethac(dim,c(2,3,4),type = 1) # Sample sample = suppressWarnings(HAC::rHAC(n,HAC)) # Maximum pseudo-likelihood estimator to be used as reference copula for bw_method = 0 est_cop = mlehac(sample,dim,1,c(2,3,4)) # Estimate mutual information between two random vectors of size 2 in different ways est_phi_1 = phinp(sample,cop = est_cop,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 0) est_phi_2 = phinp(sample,cop = est_cop,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 0) est_phi_3 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 1) est_phi_4 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 1) est_phi_5 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "beta",bw_method = 2) est_phi_6 = phinp(sample,dim = dim,phi = function(t){t * log(t)}, estimator = "trans",bw_method = 2)
This function computes the non-parametric Gaussian transformation kernel copula density estimator.
transformationestimator(input, h, pseudos)
transformationestimator(input, h, pseudos)
input |
The copula argument at which the density estimate is to be computed. |
h |
The bandwidth to be used in the Gaussian kernel. |
pseudos |
The (estimated) copula observations from a |
Given a -dimensional random vector
with
,
and samples
from
for
and
,
the Gaussian transformation kernel estimator for the copula density of
equals, at
,
where is a bandwidth parameter,
with
the (rescaled) empirical cdf of , and
the standard normal distribution function with corresponding quantile function
and density function
.
The Gaussian transformation kernel copula density estimator evaluated at the input.
De Keyser, S. & Gijbels, I. (2024). Hierarchical variable clustering via copula-based divergence measures between random vectors. International Journal of Approximate Reasoning 165:109090. doi: https://doi.org/10.1016/j.ijar.2023.109090.
betakernelestimator
for the computation of the beta kernel copula density estimator,
hamse
for local bandwidth selection for the beta kernel or Gaussian transformation kernel copula density estimator,
phinp
for fully non-parametric estimation of the -dependence between
random vectors.
q = 3 n = 100 # Sample from multivariate normal distribution with identity covariance matrix sample = mvtnorm::rmvnorm(n,rep(0,q),diag(3),method = "chol") # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Argument at which to estimate the density input = rep(0.5,q) # Local bandwidth selection h = hamse(input,pseudos = pseudos,n = n,estimator = "trans",bw_method = 1) # Gaussian transformation kernel estimator est_dens = transformationestimator(input,h,pseudos) # True density true = copula::dCopula(rep(0.5,q), copula::normalCopula(0, dim = q))
q = 3 n = 100 # Sample from multivariate normal distribution with identity covariance matrix sample = mvtnorm::rmvnorm(n,rep(0,q),diag(3),method = "chol") # Copula pseudo-observations pseudos = matrix(0,n,q) for(j in 1:q){pseudos[,j] = (n/(n+1)) * ecdf(sample[,j])(sample[,j])} # Argument at which to estimate the density input = rep(0.5,q) # Local bandwidth selection h = hamse(input,pseudos = pseudos,n = n,estimator = "trans",bw_method = 1) # Gaussian transformation kernel estimator est_dens = transformationestimator(input,h,pseudos) # True density true = copula::dCopula(rep(0.5,q), copula::normalCopula(0, dim = q))