Skip to content

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).

Definition: Spherical and elliptical random vectors

A random vector X is said to be spherical if for all orthogonal matrix AOd(R), AXX.

For every matrix B and vector c, the random vector BX+c is then said to be elliptical.

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 AOd(R),

ϕ(t)=E(et,X)=E(et,AX)=E(eAt,X)=ϕ(At).

We can therefore express this characteristic function as ϕ(t)=ψ(t22), where ψ is a function that characterizes the spherical family, called the generator of the family. Any characteristic function that can be expressed as a function of the norm of its argument is the characteristic function of a spherical random vector, since At2=t2 for any orthogonal matrix A.

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

ϕ(t)=i=1nϕi(t)=i=1nψi(t22)=ψ(t22),

which is still a function of only the norm of t.

To fix ideas, for Gaussian random vectors, ψ(t)=et22.

Sampling with Distributions.jl

Elliptical random vectors in the Gaussian and Student families are available from Distributions.jl:

julia
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]
)
julia
T = MvTDist(ν,Σ)
Distributions.GenericMvTDist{Float64, PDMats.PDMat{Float64, Matrix{Float64}, LinearAlgebra.Cholesky{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:

C=F(F11,...,Fd1),

where Fi1 denotes the almost-inverse of Fi, that is:

u[0,1],Fi1(u)=inf{x:Fi(x)u},

and Fi is usually hard to express from the elliptical assumptions.

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 [2325] 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., [2628] among others. See also [29] for a recent work on nonparametric estimation of the underlying univariate spherical distribution.

Note on internal implementation

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:

julia
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:

julia
using Copulas, Distributions
Σ = [1 0.5
    0.5 1] # variance-covariance matrix.
ν = 3 # number of degrees of freedom
C = TCopula(ν,Σ)
TCopula{2, Int64, 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:

julia
u = rand(C,1000)
= fit(GaussianCopula,u) # to fit on the sampled data.
GaussianCopula{2, Matrix{Float64}}(Σ = [1.0 0.5069034434223326; 0.5069034434223326 1.0]))

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:

julia
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)

julia
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

julia
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 X=(X1,,Xd) with correlation matrix Σ and univariate CDFs (Fi), conditioning follows the standard elliptical identities. Partition indices as IJ={1,,d} and conformably partition Σ as

Σ=(ΣIIΣIJΣJIΣJJ).
  • For the Gaussian copula, the conditional law XI|XJ=xJ is Gaussian with μI|J=ΣIJΣJJ1xJ,ΣI|J=ΣIIΣIJΣJJ1ΣJI. Mapping to the copula scale with uk=Φ(xk) and xk=Φ1(uk) yields the conditional copula via CI|J(uIuJ)=Pr[XIΦ1(uI)|XJ=Φ1(uJ)], and the univariate conditional distortions Hi|J(uuJ)=Pr[XiΦ1(u)|XJ=Φ1(uJ)]=Φ(Φ1(u)μi|JΣi|J).

  • For the Student-t copula with degrees of freedom ν, one uses the standard conditional-t result: XI|XJ=xJtp(μI|J,ν+qJν+rJΣI|J,ν+|J|), where qJ=|J| and rJ=(xJ)ΣJJ1xJ.

      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
julia
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 C to be defined as :

C=F(F11,...,Fd1),

where F and F1,...,Fd are respectively the multivariate distribution function of some elliptical random vector and the univariate distribution function of its marginals. For a type 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 returns MvNormal from Distributions.jl.

  • U(::Type{MyCOp}), returning the constructor for the univariate marginal, usually in standardized form. For example, U(GaussianCopula) returns Normal from Distributions.jl.

From these two functions, the abstract type provides a fully functional copula.

Details

Recall the definition of spherical random vectors:

Definition - Spherical and elliptical random vectors

A random vector X is said to be spherical if for all orthogonal matrix AOd(R), AXX.

For every matrix B and vector c, the random vector BX+c is then said to be elliptical.

Recall that spherical random vectors are random vectors which characteristic functions (c.f.) only depend on the norm of their arguments. Indeed, for any AOd(R),

ϕ(t)=E(et,X)=E(et,AX)=E(eAt,X)=ϕ(At).

We can therefore express this characteristic function as ϕ(t)=ψ(t22), where ψ is a function that characterizes the spherical family, called the generator of the family. Any characteristic function that can be expressed as a function of the norm of its argument is the characteristic function of a spherical random vector, since At2=t2 for any orthogonal matrix A.

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:

julia
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.
source

Available models

GaussianCopula

Copulas.GaussianCopula Type
julia
GaussianCopula{d, MT}

Fields:

  • Σ::MT — correlation matrix (the constructor coerces the input to a correlation matrix).

Constructors

julia
GaussianCopula(Σ)
GaussianCopula(d, ρ)
GaussianCopula{d}(Σ)
GaussianCopula{d}(ρ)

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 ρ:

julia
Σ = 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, the resulting GaussianCopula represents independence, as it does for any diagonal matrix.

The Gaussian copula is the copula of a multivariate normal distribution. It is defined by

C(x;Σ)=FΣ(FΣ,11(x1),,FΣ,d1(xd)),

where FΣ is the cdf of a centered multivariate normal with covariance/correlation Σ and FΣ,i its i-th marginal cdf.

Example usage:

julia
C = GaussianCopula(Σ)
u = rand(C, 1000)
pdf(C, u); cdf(C, u)
Ĉ = fit(GaussianCopula, u)

Special case:

  • If isdiag(Σ), the GaussianCopula represents independence while retaining its concrete family type.

References:

  • [3] Nelsen, Roger B. An introduction to copulas. Springer, 2006.
source

Targeting a Pearson correlation: the Nataf correction

The parameter matrix of a GaussianCopula is the correlation matrix of the underlying Gaussian random vector. When the copula is coupled to non-Gaussian marginals through SklarDist, that parameter is not the Pearson correlation of the resulting random vector, because Pearson correlation depends on the marginals (only rank-based measures such as Kendall's τ or Spearman's ρ are marginal-free, see the dependence measures page):

julia
using Copulas, Distributions, Statistics, Random
rng = Xoshiro(1)
C = GaussianCopula([1.0 0.7; 0.7 1.0])
D = SklarDist(C, (LogNormal(0, 0.8), LogNormal(0, 0.8)))
cor(rand(rng, D, 10^5)') # although the copula parameter is 0.7...
2×2 Matrix{Float64}:
 1.0       0.631666
 0.631666  1.0

The Nataf correction [20, 21] inverts this distortion: it computes the copula parameter matrix that makes the SklarDist attain a target Pearson correlation matrix for the given marginals:

julia
m  = (LogNormal(0, 0.8), LogNormal(0, 0.8))
R₀ = Nataf(m, [1.0 0.7; 0.7 1.0])
2×2 Matrix{Float64}:
 1.0       0.761043
 0.761043  1.0
julia
D = SklarDist(GaussianCopula(R₀), m)
cor(rand(rng, D, 10^5)') # ≈ 0.7 as requested.
2×2 Matrix{Float64}:
 1.0       0.702896
 0.702896  1.0

Since non-Gaussian marginals cannot attain every Pearson correlation (the Fréchet-Hoeffding bounds of the pair), an unattainable target throws an error reporting the attainable range. Pairs among Normal, LogNormal, and Uniform margins use closed-form corrections; other marginals go through a Gauss-Hermite quadrature.

Copulas.Nataf Function
julia
Nataf(margins, R; nodes=32)
Nataf(margins, ρ::Real; nodes=32)

Nataf correction [20, 21]: compute the correlation matrix for a GaussianCopula such that the SklarDist built from it and the given margins has Pearson correlation matrix R.

A Gaussian copula with parameter ρ0 induces, once the margins are applied, a Pearson correlation that depends on the shape of the margins and equals ρ0 only when the margins are themselves Gaussian. Matching a Pearson target ρ therefore means inverting, for each pair of margins,

ρ(ρ0)=E[gi(Zi)gj(Zj)],(Zi,Zj)N(0,(1ρ0ρ01)),

where gk(z)=(Fk1(Φ(z))μk)/σk is the standardized margin pulled back to standard normal space. The expectation is evaluated with a product Gauss-Hermite rule and, since it is increasing in ρ0, inverted by a bracketed root search.

Arguments

  • margins: a Tuple or vector of univariate distributions, each with finite mean and finite positive standard deviation.

  • R: the target Pearson correlation matrix (or a single target correlation ρ when there are exactly two margins, in which case the corrected scalar is returned).

  • nodes: number of Gauss-Hermite nodes per dimension. The default is accurate to about 1e-8 for well-behaved margins; heavy-tailed or strongly skewed margins converge more slowly and want more nodes.

Zero targets map to exactly zero. Pairs whose induced correlation is known analytically skip the quadrature and use the closed form instead: Normal-Normal pairs (the identity, so Gaussian margins reproduce R exactly), LogNormal-LogNormal pairs (ρ0=log(1+ρ(esi21)(esj21))/(sisj)), and all pairs among Normal, LogNormal, and Uniform margins. Because non-Gaussian margins cannot attain every Pearson correlation (the Fréchet-Hoeffding bounds), a target outside the attainable range throws an error naming the pair and the range. Targets on the attainable boundary snap just inside ±1, so the result stays usable by the GaussianCopula constructor; the corrected matrix is nevertheless not guaranteed to stay positive definite for extreme targets in dimension d>2, and the GaussianCopula constructor validates it.

The computation is type-generic and follows the precision of the inputs: BigFloat targets or margin parameters yield BigFloat results, at full precision on the closed-form paths. Two caveats on the generic quadrature path: its nodes are computed in Float64, and it requires margins whose quantile accepts the working type — some quantiles in Distributions.jl (e.g. Gamma, Beta) are implemented for machine floats only and throw a MethodError for BigFloat arguments.

Example

julia
using Copulas, Distributions, Statistics

m  = (LogNormal(0, 0.8), Gamma(1, 2), Beta(1, 2))
R0 = [1 0.7 0.3; 0.7 1 0.5; 0.3 0.5 1]

D = SklarDist(GaussianCopula(Nataf(m, R0)), m)
cor(rand(D, 10^6)') # ≈ R0, while GaussianCopula(R0) directly would miss the target.

References:

  • [20] Nataf, A. (1962). Détermination des distributions de probabilités dont les marges sont données.

  • [21] Liu, P.-L., & Der Kiureghian, A. (1986). Multivariate distribution models with prescribed marginals and covariances.

source

TCopula

Copulas.TCopula Type
julia
TCopula{d, Tν, MT}

Fields:

  • df::Tν — degrees of freedom

  • Σ::MT — correlation matrix

Constructor

julia
TCopula(df, Σ)
TCopula{d}(df, Σ)

The Student t copula is the copula of a multivariate Student t distribution. It is defined by

C(x;ν,Σ)=Fν,Σ(Fν,Σ,11(x1),,Fν,Σ,d1(xd)),

where Fν,Σ is the cdf of a centered multivariate t with correlation Σ and ν degrees of freedom.

Example usage:

julia
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.
source

References

  1. R. B. Nelsen. An Introduction to Copulas. 2nd ed Edition, Springer Series in Statistics (Springer, New York, 2006).

  2. A. Nataf. Détermination des distributions de probabilités dont les marges sont données. Comptes Rendus de l'Académie des Sciences 255, 42–43 (1962).

  3. P.-L. Liu and A. Der Kiureghian. Multivariate distribution models with prescribed marginals and covariances. Probabilistic Engineering Mechanics 1, 105–112 (1986).

  4. G. Frahm, M. Junker and A. Szimayer. Elliptical Copulas: Applicability and Limitations. Statistics & Probability Letters 63, 275–286 (2003).

  5. 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).

  6. M.-P. Côté and C. Genest. Dependence in a Background Risk Model. Journal of Multivariate Analysis 172, 28–46 (2019).

  7. 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.

  8. 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).

  9. 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).

  10. A. Derumigny and J.-D. Fermanian. Identifiability and Estimation of Meta-Elliptical Copula Generators. Journal of Multivariate Analysis, 104962 (2022).