Elliptical family
Definition
The easiest families of copulas are the one derived from known families of random vectors, and the first presented one are, generally, the Elliptical families (in particular, the Gaussian and Student families are very standard in the litterature).
A random vector
For every matrix
Spherical random vectors have several interesting properties. First, the shape of the distribution must be the same in every direction since it is stable by rotations. Moreover, their characteristic functions (c.f.) only depend on the norm of their arguments. Indeed, for any
We can therefore express this characteristic function as
This class contains the (multivariate) Normal and Student distributions, and it is easy to construct others if needed. This is a generalization of the family of Gaussian random vectors, and they benefit from several nice properties of the former, among which, particularly interesting, the stability by convolution. Indeed, convolutions correspond to product of characteristic functions, and
which is still a function of only the norm of
To fix ideas, for Gaussian random vectors,
Elliptical random vectors in the Gaussian and Student families are available from Distributions.jl:
using Distributions
Σ = [1 0.5
0.5 1] # variance-covariance matrix.
ν = 3 # number of degrees of freedom for the student.
N = MvNormal(Σ)ZeroMeanFullNormal(
dim: 2
μ: Zeros(2)
Σ: [1.0 0.5; 0.5 1.0]
)T = MvTDist(ν,Σ)Distributions.GenericMvTDist{Float64, PDMats.PDMat{Float64, Matrix{Float64}}, FillArrays.Zeros{Float64, 1, Tuple{Base.OneTo{Int64}}}}(
df: 3.0
dim: 2
μ: Zeros(2)
Σ: [1.0 0.5; 0.5 1.0]
)Elliptical copulas are simply copulas of elliptical distributions. This simplicity of definition is paid for in the expression of the copulas itself: the obtained function has usually no better expression than:
where
and
Moreover, the form of dependence structures that can be reached inside this class is restricted. The elliptical copulas are parametrized by the corresponding univariate spherical generator and a correlation matrix, which is a very simple structure. See also [22–24] for details on these copulas.
On the other hand, there exist performant estimators of high-dimensional covariance matrices, and a large theory is built on the elliptical assumption of high dimensional random vectors, see e.g., [25–27] among others. See also [28] for a recent work on nonparametric estimation of the underlying univariate spherical distribution.
If the exposition we just did on characteristic functions of Elliptical random vectors is fundamental to the definition of elliptical copulas, the package does not use this at all to function, and rather rely on the existence of multivariate and corresponding univariate families of distributions in Distributions.jl.
You can obtain these elliptical copulas by the following code:
using Copulas
Σ = [1 0.5
0.5 1] # variance-covariance matrix.
ν = 3 # number of degrees of freedom for the student.
C_N = GaussianCopula(Σ)
C_T = TCopula(ν,Σ)Examples
To construct, e.g., a Student copula, you need to provide the Correlation matrix and the number of degree of freedom, as follows:
using Copulas, Distributions
Σ = [1 0.5
0.5 1] # variance-covariance matrix.
ν = 3 # number of degrees of freedom
C = TCopula(ν,Σ)TCopula{2, 3, Matrix{Float64}}(Σ = [1.0 0.5; 0.5 1.0]))You can sample it and compute its density and distribution functions via the standard interface. We could try to fit a GaussianCopula on the sampled data, even if we already know that the tails will not be properly taken into account:
u = rand(C,1000)
Ĉ = fit(GaussianCopula,u) # to fit on the sampled data.GaussianCopula{2, Matrix{Float64}}(Σ = [0.9999999999999999 0.5249307454482931; 0.5249307454482931 0.9999999999999999]))We see that the estimation we have on the correlation matrix is quite good, but rest assured that the tails of the distributions are not the same at all. To see that, let's plot the lower tail function (see [3]) for both copulas:
using Plots
chi(C,u) = 2 * log(1-u) / log(1 - 2u + cdf(C,[u,u])) -1
u = 0.5:0.03:0.99
plot(u, chi.(Ref(C),u), label="True student copula")
plot!(u, chi.(Ref(Ĉ),u), label="Estimated Gaussian copula")
Visual: Gaussian vs Student (same correlation)
using Plots
Σ = [1 0.7; 0.7 1]
ν = 4
CG = GaussianCopula(Σ)
CT = TCopula(ν, Σ)
plot(plot(CG), plot(CT); layout=(1,2))
Conditional on original scale via SklarDist
XG = SklarDist(CG, (Normal(), Normal()))
XT = SklarDist(CT, (Normal(), Normal()))
X1G = condition(XG, 2, 0.0)
X1T = condition(XT, 2, 0.0)
xgrid = range(quantile(X1T, 0.001), quantile(X1T, 0.999); length=401)
plot(xgrid, Distributions.cdf.(Ref(X1G), xgrid); label="Gaussian", xlabel="x", ylabel="cdf",
title="F_{X1|X2=0}")
plot!(xgrid, Distributions.cdf.(Ref(X1T), xgrid); label="Student")
The difference between the two is not very strong.
Conditionals and distortions
For an elliptical copula built from an underlying elliptical vector
For the Gaussian copula, the conditional law
is Gaussian with Mapping to the copula scale with and yields the conditional copula via and the univariate conditional distortions For the Student-
copula with degrees of freedom , one uses the standard conditional- result: , where and . With $u_k = F_t(x_k;\,\nu)$ and $x_k = F_t^{-1}(u_k;\,\nu)$ (standard univariate $t$ with df $\nu$), this provides closed forms for $C_{I|J}$ and for $$H_{i|J}(u\mid\boldsymbol u_J) = F_t\!\Big(\,F_t^{-1}(u;\,\nu)\,;\,\mu_{i|J},\,\tfrac{\nu + r_J}{\nu + q_J}\,\Sigma_{i|J},\,\nu+|J|\Big),$$ where $q_J=|J|$, $r_J= x_J^\top\Sigma_{JJ}^{-1}x_J$, and $F_t(\cdot;\,\mu,\sigma^2,\nu)$ is the univariate non-standard $t$ CDF.
These formulas are what the implementation relies on (via SklarDist for original scale and via marginal CDF transforms for the copula scale) to compute condition and the associated distortions efficiently.
Copulas.EllipticalCopula Type
EllipticalCopula{d,MT}This is an abstract type. It implements an interface for all Elliptical copulas. We construct internally elliptical copulas using the sklar's theorem, by considering the copula
where MyCop <: EllipitcalCopula, it is necessary to implement the following methods:
N(::Type{MyCOp}), returning the constructor of the elliptical random vector from its correlation matrix. For example,N(GaussianCopula)simply returnsMvNormalfromDistributions.jl.U(::Type{MyCOp}), returning the constructor for the univariate marginal, usually in standardized form. For example,U(GaussianCopula)returnsNormalfromDistributions.jl.
From these two functions, the abstract type provides a fully functional copula.
Details
Recall the definition of spherical random vectors:
A random vector
For every matrix
Recall that spherical random vectors are random vectors which characteristic functions (c.f.) only depend on the norm of their arguments. Indeed, for any
We can therefore express this characteristic function as
However, note that this is not how the underlying code is working, we do not check for validity of the proposed generator (we dont even use it). You can construct such an elliptical family using simply Sklar:
struct MyElliptical{d,T} <: EllipticalCopula{d,T}
θ:T
end
U(::Type{MyElliptical{d,T}}) where {d,T} # Distribution of the univaraite marginals, Normal() for the Gaussian case.
N(::Type{MyElliptical{d,T}}) where {d,T} # Distribution of the mutlivariate random vector, MvNormal(C.Σ) for the Gaussian case.These two functions are enough to implement the rest of the interface.
References:
- [3] Nelsen, Roger B. An introduction to copulas. Springer, 2006.
Available models
GaussianCopula
Copulas.GaussianCopula Type
GaussianCopula{d, MT}Fields:
Σ::MT— correlation matrix (the constructor coerces the input to a correlation matrix).
Constructors
GaussianCopula(Σ)
GaussianCopula(d, ρ)
GaussianCopula(d::Integer, ρ::Real)Where Σ is a (symmetric) covariance or correlation matrix. The two-argument form with (d, ρ) builds the equicorrelation matrix with ones on the diagonal and constant off-diagonal correlation ρ:
Σ = fill(ρ, d, d); Σ[diagind(Σ)] .= 1
C = GaussianCopula(d, ρ) # == GaussianCopula(Σ)Validity domain (equicorrelated PD matrix): -1/(d-1) < ρ < 1. The boundary ρ = -1/(d-1) is singular and rejected. If ρ == 0, this returns IndependentCopula(d) (same fast-path as when passing a diagonal matrix).
The Gaussian copula is the copula of a multivariate normal distribution. It is defined by
where
Example usage:
C = GaussianCopula(Σ)
u = rand(C, 1000)
pdf(C, u); cdf(C, u)
Ĉ = fit(GaussianCopula, u)Special case:
- If
isdiag(Σ), the constructor returnsIndependentCopula(d).
References:
- [3] Nelsen, Roger B. An introduction to copulas. Springer, 2006.
TCopula
Copulas.TCopula Type
TCopula{d, df, MT}Fields:
df::Int— degrees of freedomΣ::MT— correlation matrix
Constructor
TCopula(df, Σ)The Student t copula is the copula of a multivariate Student t distribution. It is defined by
where
Example usage:
C = TCopula(2, Σ)
u = rand(C, 1000)
pdf(C, u); cdf(C, u)
Ĉ = fit(TCopula, u)References:
- [3] Nelsen, Roger B. An introduction to copulas. Springer, 2006.
References
R. B. Nelsen. An Introduction to Copulas. 2nd ed Edition, Springer Series in Statistics (Springer, New York, 2006).
G. Frahm, M. Junker and A. Szimayer. Elliptical Copulas: Applicability and Limitations. Statistics & Probability Letters 63, 275–286 (2003).
E. Gómez, M. A. Gómez-villegas and J. M. Marín. A Survey on Continuous Elliptical Vector Distributions. Revista Matemática Complutense 16, 345–361 (2003).
M.-P. Côté and C. Genest. Dependence in a Background Risk Model. Journal of Multivariate Analysis 172, 28–46 (2019).
G. Elidan. Copulas in Machine Learning. In: Copulae in Mathematical and Quantitative Finance, Vol. 213, edited by P. Jaworski, F. Durante and W. K. Härdle (Springer Berlin Heidelberg, Berlin, Heidelberg, 2013); pp. 39–60.
J. Friedman, T. Hastie and R. Tibshirani. Applications of the Lasso and Grouped Lasso to the Estimation of Sparse Graphical Models (Technical report, Stanford University, 2010).
D. Müller and C. Czado. Dependence Modelling in Ultra High Dimensions with Vine Copulas and the Graphical Lasso. Computational Statistics & Data Analysis 137, 211–232 (2019).
A. Derumigny and J.-D. Fermanian. Identifiability and Estimation of Meta-Elliptical Copula Generators. Journal of Multivariate Analysis, 104962 (2022).