DatagenCopulaBased.AmhCopulaType
AmhCopula

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

AmhCopula(n::Int, θ::Real)

The Ali-Mikhail-Haq copula parameterized by θ, domain: θ ∈ (0, 1) for n > 2 and θ ∈ [-1, 1] for n = 2.

Constructor

AmhCopula(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero. Such correlation must be grater than zero and limited from above due to the θ domain. - Spearman correlation must be in range (0, 0.5) - Kendall correlation must be in range (0, 1/3)

julia> AmhCopula(4, .3)
AmhCopula(4, 0.3)

julia> AmhCopula(4, .3, KendallCorrelation)
AmhCopula(4, 0.9999)

DatagenCopulaBased.AmhCopulaRevType
AmhCopulaRev

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

AmhCopulaRev(n::Int, θ::Real)

The reversed Ali-Mikhail-Haq copula parametrized by θ, i.e. such that the output is 1 .- u, where u is modelled by the corresponding AMH copula. Domain: θ ∈ (0, 1) for n > 2 and θ ∈ [-1, 1] for n = 2.

Constructor

AmhCopulaRev(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero. Such correlation must be grater than zero and limited from above due to the θ domain. - Spearman correlation must be in range (0, 0.5) - Kendall correlation must be in range (0, 1/3)

julia> AmhCopulaRev(4, .3)
AmhCopulaRev(4, 0.3)
DatagenCopulaBased.ChainArchimedeanCopulasType
ChainArchimedeanCopulas

Subsequent pairs of marginals are modeled by bi-variate copulas form the Archimedean family, following copulas are supported: "Clayton", "Frank", "Ali-Mikhail-Haq", "Gumbel" copula is not supported.

Fields:

• n::Int - number of variables
• θ::Vector{Real} - a vector of parameters
• copulas::Vector{String} - a vector indicating bi-variate copulas.

possible elements "clayton", "frank", "amh"

Constructor

ChainArchimedeanCopulas(θ::Vector{Real}, copulas::Vector{String})

requires length(θ) = length(copulas) and limitations on θ for particular bi-variate copulas

Constructor

ChainArchimedeanCopulas(θ::Vector{Real}, copulas::String)

one copula family for all subsequent pairs of marginals.

Constructors

ChainArchimedeanCopulas(θ::Vector{Real}, copulas::Vector{String}, cor::Type{<:CorrelationType})

ChainArchimedeanCopulas(θ::Vector{Real}, copulas::String, cor::Type{<:CorrelationType})

For computing copula parameters from expected correlation use empty type cor::Type{<:CorrelationType}. cor ∈ {SpearmanCorrelation, KendallCorrelation} uses these correlations in the place of θ in the constructor to compute θ.

In all cases n = length(θ)+1.


julia> c = ChainArchimedeanCopulas([4., 11.], "frank")
ChainArchimedeanCopulas(3, [4.0, 11.0], ["frank", "frank"])

julia> c = ChainArchimedeanCopulas([.5, .7], ["frank", "clayton"], "Kendall")
ChainArchimedeanCopulas(3, [5.736282707019972, 4.666666666666666], ["frank", "clayton"])

DatagenCopulaBased.ChainFrechetCopulasType
ChainFrechetCopulas

Chain of bi-variate Frechet copulas. Models each subsequent pair of marginals by the bi-variate Frechet copula.

Fields: - n::Int - number of marginals - α::Vector{Real} - vector of parameters for the maximal copula - β::Vector{Real} - vector of parameters for the minimal copula

Here α[i] and β[i] parameterized bi-variate Frechet copula between i th and i+1 th marginals.

Constructors

ChainFrechetCopulas(α::Vector{Real})

here β = zero(0)

ChainFrechetCopulas(α::Vector{Real}, β::Vector{Real})
julia> ChainFrechetCopulas([0.2, 0.3, 0.4])
ChainFrechetCopulas(4, [0.2, 0.3, 0.4], [0.0, 0.0, 0.0])

julia> ChainFrechetCopulas([0.2, 0.3, 0.4], [0.1, 0.1, 0.1])
ChainFrechetCopulas(4, [0.2, 0.3, 0.4], [0.1, 0.1, 0.1])
DatagenCopulaBased.ClaytonCopulaType
ClaytonCopula

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

ClaytonCopula(n::Int, θ::Real)

The Clayton n variate copula parameterized by θ::Real, such that θ ∈ (0, ∞) for n > 2 and θ ∈ [-1, 0) ∪ (0, ∞) for n = 2, supported for n::Int ≥ 2.

Constructor

ClaytonCopula(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.

julia> ClaytonCopula(4, 3.)
ClaytonCopula(4, 3.0)

julia> ClaytonCopula(4, 0.9, SpearmanCorrelation)
ClaytonCopula(4, 5.5595567742323775)
DatagenCopulaBased.ClaytonCopulaRevType
ClaytonCopulaRev

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

ClaytonCopulaRev(n::Int, θ::Real)

The reversed Clayton copula parameterized by θ::Real (reversed means u → 1 .- u). Domain: θ ∈ (0, ∞) for n > 2 and θ ∈ [-1, 0) ∪ (0, ∞) for n = 2, supported for n::Int ≧ 2.

Constructor

ClaytonCopulaRev(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> ClaytonCopulaRev(4, 3.)
ClaytonCopulaRev(4, 3.0)

julia> ClaytonCopulaRev(4, 0.9, SpearmanCorrelation)
ClaytonCopulaRev(4, 5.5595567742323775)

DatagenCopulaBased.DoubleNestedGumbelCopulaType
DoubleNestedGumbelCopula

Fields:

• children::Vector{Nested _Gumbel _cop} vector of children copulas
• θ::Real - parameter of parent copula, domain θ ∈ [1,∞).

Constructor

Double_Nested_Gumbel _cop(children::Vector{NestedGumbelCopula}, θ::Real)

requires sufficient nesting condition for θ and child copulas.

Constructor

Doulbe_NestedGumbelCopula(children::Vector{NestedGumbelCopula}, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> a = GumbelCopula(2, 5.)
GumbelCopula(2, 5.0)

julia> b = GumbelCopula(2, 6.)
GumbelCopula(2, 6.0)

julia> c = GumbelCopula(2, 5.5)
GumbelCopula(2, 5.5)

julia> p1 = NestedGumbelCopula([a,b], 1, 2.)
NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 5.0), GumbelCopula(2, 6.0)], 1, 2.0)

julia> p2 = NestedGumbelCopula([c], 2, 2.1)
NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 5.5)], 2, 2.1)

julia> DoubleNestedGumbelCopula([p1, p2], 1.5)
DoubleNestedGumbelCopula(NestedGumbelCopula[NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 5.0), GumbelCopula(2, 6.0)], 1, 2.0), NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 5.5)], 2, 2.1)], 1.5)
DatagenCopulaBased.FrankCopulaType
FrankCopula

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

FrankCopula(n::Int, θ::Real)

The Frank n variate copula parameterized by θ::Real. Domain: θ ∈ (0, ∞) for n > 2 and θ ∈ (-∞, 0) ∪ (0, ∞) for n = 2, supported for n::Int ≧ 2.

Constructor

FrankCopula(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.

julia> FrankCopula(2, -5.)
FrankCopula(2, -5.0)

julia> FrankCopula(4, .3)
FrankCopula(4, 0.3)
DatagenCopulaBased.FrechetCopulaType
FrechetCopula

The Frechet copula

Fileds:

• n - number of marginals
• α - the parameter of the maximal copula
• β - the parameter of the minimal copula

Constructor

FrechetCopula(n::Int, α::Real)

The one parameter Frechet copula is a combination of maximal copula with weight α and independent copula with weight 1-α.

Constructor

FrechetCopula(n::Int, α::Real, β::Real)

The two parameters Frechet copula C = α C{max} + β C{min} + (1- α - β) C{⟂}, supported only for n = 2.

julia> FrechetCopula(4, 0.5)
FrechetCopula(4, 0.5, 0.0)

julia> FrechetCopula(2, 0.5, 0.3)
FrechetCopula(2, 0.5, 0.3)
DatagenCopulaBased.GaussianCopulaType
GaussianCopula

Gaussian copula

Fields:

• Σ - the correlation matrix must be symmetric, positively defined and with ones on diagonal

Constructor

GaussianCopula(Σ::Matrix{T}) where T <: Real

julia> GaussianCopula([1. 0.5; 0.5 1.])
GaussianCopula([1.0 0.5; 0.5 1.0])

DatagenCopulaBased.GumbelCopulaType
GumbelCopula

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

    GumbelCopula(n::Int, θ::Real)

The Gumbel n variate copula is parameterized by θ::Real ∈ [1, ∞), supported for n::Int ≧ 2.

Constructor

GumbelCopula(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> GumbelCopula(4, 3.)
GumbelCopula(4, 3.0)

julia> GumbelCopula(4, .75, KendallCorrelation)
GumbelCopula(4, 4.0)
DatagenCopulaBased.GumbelCopulaRevType
GumbelCopulaRev

Fields:

• n::Int - number of marginals
• θ::Real - parameter

Constructor

GumbelCopulaRev(n::Int, θ::Real)

The reversed Gumbel copula (reversed means u → 1 .- u), parameterized by θ::Real ∈ [1, ∞), supported for n::Int ≧ 2.

Constructor

GumbelCopulaRev(n::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.

julia> c = GumbelCopulaRev(4, .75, KendallCorrelation)
GumbelCopulaRev(4, 4.0)

julia> Random.seed!(43);

julia> simulate_copula(2, c)
2×4 Array{Float64,2}:
0.963524   0.872108  0.816626  0.783637
0.0954475  0.138451  0.13593   0.0678172
DatagenCopulaBased.HierarchicalGumbelCopulaType
HierarchicalGumbelCopula

Fields:

• n::Int - number of marginals
• θ::Vector{Real} - vector of parameters, must be decreasing and θ[end] ≧ 1, for the

sufficient nesting condition to be fulfilled.

The hierarchically nested Gumbel copula Cθₙ₋₁(Cθₙ₋₂( ... Cθ₂(Cθ₁(u₁, u₂), u₃)...uₙ₋₁) uₙ)

Constructor

HierarchicalGumbelCopula(θ::Vector{Real})

Constructor

HierarchicalGumbelCopula(ρ::Vector{Real}, cor::Type{<:CorrelationType})

For computing copula parameters from expected correlations use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlations in the place of θ in the constructor. The copula parameters will be computed then. The correlation must be greater than zero.


julia> c = HierarchicalGumbelCopula([5., 4., 3.])
HierarchicalGumbelCopula(4, [5.0, 4.0, 3.0])

julia> c = HierarchicalGumbelCopula([0.95, 0.5, 0.05], KendallCorrelation)
HierarchicalGumbelCopula(4, [19.999999999999982, 2.0, 1.0526315789473684])
DatagenCopulaBased.MarshallOlkinCopulaType
MarshallOlkinCopula

Fields:

• n::Int - number of marginals
• λ::Vector{Real} - vector of non-negative parameters λₛ, i.e.: λ = [λ₁, λ₂, ..., λₙ, λ₁₂, λ₁₃, ..., λ₁ₙ, λ₂₃, ..., λₙ₋₁ₙ, λ₁₂₃, ..., λ₁₂...ₙ] and n = ceil(Int, log(2, length(λ)-1)).

Constructor

MarshallOlkinCopula(λ)

length(λ) ≧ 3 is required

julia> MarshallOlkinCopula([0.5, 0.5, 0.6])
MarshallOlkinCopula(2, [0.5, 0.5, 0.6])

julia> MarshallOlkinCopula([0.5, 0.5, 0.6, 0.7, 0.7, 0.7, 0.8])
MarshallOlkinCopula(3, [0.5, 0.5, 0.6, 0.7, 0.7, 0.7, 0.8])
DatagenCopulaBased.NestedAmhCopulaType
NestedAmhCopula

Nested Ali-Mikhail-Haq copula, fields:

• children::Vector{AMH _cop} vector of children copulas
• m::Int ≧ 0 - number of additional marginals modeled by the parent copula only
• θ::Real - parameter of parent copula, domain θ ∈ (0,1).

Nested Ali-Mikhail-Haq copula: C _θ(C _ϕ₁(u₁₁, ..., u₁,ₙ₁), ..., C _ϕₖ(uₖ₁, ..., uₖ,ₙₖ), u₁ , ... uₘ). If m > 0, the last m variables will be modeled by the parent copula only.

Constructor

NestedAmhCopula(children::Vector{AmhCopula}, m::Int, θ::Real)

Let ϕ be the vector of parameter of children copula, sufficient nesting condition requires θ <= minimum(ϕ)

Constructor

NestedAmhCopula(children::Vector{AmhCopula}, m::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> a = AmhCopula(2, .2)
AmhCopula(2, 0.2)

julia> NestedAmhCopula([a, a], 2, 0.1)
NestedAmhCopula(AmhCopula[AmhCopula(2, 0.2), AmhCopula(2, 0.2)], 2, 0.1)

DatagenCopulaBased.NestedClaytonCopulaType
NestedClaytonCopula

Fields:

• children::Vector{ClaytonCopula} vector of children copulas
• m::Int ≧ 0 - number of additional marginals modeled by the parent copula only
• θ::Real - parameter of parent copula, domain θ > 0.

Nested Clayton copula: Cθ(Cϕ₁(u₁₁, ..., u₁,ₙ₁), ..., C_ϕₖ(uₖ₁, ..., uₖ,ₙₖ), u₁ , ... uₘ). If m > 0, the last m variables will be modeled by the parent copula only.

Constructor

NestedClaytonCopula(children::Vector{ClaytonCopula}, m::Int, θ::Real)

Let ϕ be the vector of parameter of children copula, sufficient nesting condition requires θ <= minimum(ϕ)

Constructor

NestedClaytonCopula(children::Vector{ClaytonCopula}, m::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.

julia> a = ClaytonCopula(2, 2.)
ClaytonCopula(2, 2.0)

julia> NestedClaytonCopula([a], 2, 0.5)
NestedClaytonCopula(ClaytonCopula[ClaytonCopula(2, 2.0)], 2, 0.5)

julia> NestedClaytonCopula([a, a], 2, 0.5)
NestedClaytonCopula(ClaytonCopula[ClaytonCopula(2, 2.0), ClaytonCopula(2, 2.0)], 2, 0.5)

DatagenCopulaBased.NestedFrankCopulaType
NestedFrankCopula

Fields:

• children::Vector{FrankCopula} vector of children copulas
• m::Int ≧ 0 - number of additional marginals modeled by the parent copula only
• θ::Real - parameter of parent copula, domain θ ∈ (0,∞).

Nested Frank copula: C _θ(C _ϕ₁(u₁₁, ..., u₁,ₙ₁), ..., C _ϕₖ(uₖ₁, ..., uₖ,ₙₖ), u₁ , ... uₘ). If m > 0, the last m variables will be modeled by the parent copula only.

Constructor

NestedFrankCopula(children::Vector{FrankCopula}, m::Int, θ::Real)

Let ϕ be the vector of parameter of children copula, sufficient nesting condition requires θ <= minimum(ϕ)

Constructor

NestedFrankCopula(children::Vector{Frank_ cop}, m::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> a = FrankCopula(2, 5.)
FrankCopula(2, 5.0)

julia> NestedFrankCopula([a, a], 2, 0.1)
NestedFrankCopula(FrankCopula[FrankCopula(2, 5.0), FrankCopula(2, 5.0)], 2, 0.1)
DatagenCopulaBased.NestedGumbelCopulaType
NestedGumbelCopula

Fields:

• children::Vector{GumbelCopula} vector of children copulas
• m::Int ≧ 0 - number of additional marginals modeled by the parent copula only
• θ::Real - parameter of parent copula, domain θ ∈ [1,∞).

Nested Gumbel copula: C _θ(C _ϕ₁(u₁₁, ..., u₁,ₙ₁), ..., C _ϕₖ(uₖ₁, ..., uₖ,ₙₖ), u₁ , ... uₘ). If m > 0, the last m variables will be modeled by the parent copula only.

Constructor

NestedGumbelCopula(children::Vector{GumbelCopula}, m::Int, θ::Real)

Let ϕ be the vector of parameter of children copula, sufficient nesting condition requires θ <= minimum(ϕ)

Constructor

NestedGumbelCopula(children::Vector{GumbelCopula}, m::Int, θ::Real, cor::Type{<:CorrelationType})

For computing copula parameter from expected correlation use empty type cor::Type{<:CorrelationType} where SpearmanCorrelation <:CorrelationType and KendallCorrelation<:CorrelationType. If used cor put expected correlation in the place of θ in the constructor. The copula parameter will be computed then. The correlation must be greater than zero.


julia> a = GumbelCopula(2, 5.)
GumbelCopula(2, 5.0)

julia> NestedGumbelCopula([a, a], 2, 2.1)
NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 5.0), GumbelCopula(2, 5.0)], 2, 2.1)
DatagenCopulaBased.StudentCopulaType
StudentCopula

t-Student copula

fields

• Σ::Matrix{Real} - the correlation matrix must be symmetric, positively defined and with ones on diagonal
• ν::Int - the parameter n.o. degrees of freedom we require ν > 0

Constructor:

StudentCopula(Σ::Matrix{Real}, ν::Int)

julia> StudentCopula([1. 0.5; 0.5 1.], 4)
StudentCopula([1.0 0.5; 0.5 1.0], 4)

DatagenCopulaBased.amh_genMethod
amh_gen(r::Vector{Real}, θ::Real)

Given a vector of random numbers r of size n+1, return the sample from the AMH copula parametrised by θ of the size n.

DatagenCopulaBased.clayton_genMethod
clayton_gen(r::Vector{Real}, θ::Real)

Given a vector of random numbers r of size n+1, return the sample from the Clayton copula parametrised by θ of the size n.

DatagenCopulaBased.convertmarg!Function

convertmarg!(X::Matrix, d::UnionAll, p::Vector{Vector})

Takes matrix X of realizations of size(X,2) = n dimensional random variable, with uniform marginals numbered by i, and convert those marginals to common distribution d with parameters p[i]. If testunif = true each marginal is tested for uniformity.

julia> Random.seed!(43);

julia> x = rand(10,2);

julia> convertmarg!(x, Normal, [[0, 1],[0, 10]])

julia> x
10×2 Array{Float64,2}:
-0.911655    4.17328
0.756673  -14.4472
1.22088   -11.4823
1.43866   -13.1053
-0.231978  -11.2415
1.35696     6.43914
0.949145  -26.0172
-0.251957  -18.9723
-0.177808Real4172
1.70477    10.4192
DatagenCopulaBased.cormatgenFunction
cormatgen(n::Int = 20)

Returns symmetric correlation matrix Σ of size n x n. Method:

a = rand(n,n)
b = a*a'
c = b./maximum(b)

Example:

julia> Random.seed!(43);

julia> cormatgen(2)
2×2 Array{Float64,2}:
1.0       0.660768
0.660768  1.0
DatagenCopulaBased.cormatgen_constantMethod
cormatgen_constant(n::Int, α::Real)

Returns the constant correlation matrix with constant correlations equal to 0 <= α <= 1

julia> cormatgen_constant(2, 0.5)
2×2 Array{Real,2}:
1.0  0.5
0.5  1.0
DatagenCopulaBased.cormatgen_constant_noisedMethod
cormatgen_constant_noised(n::Int, α::Real; ϵ::Real = (1 .-α)/2.)

Returns the constant correlation matrix of size n x n with constant correlations equal to 0 <= α <= 1 and additinal noise determinde by ϵ.

julia> Random.seed!(43);

julia> cormatgen_constant_noised(3, 0.5)
3×3 Array{Float64,2}:
1.0       0.506271  0.285793
0.506271  1.0       0.475609
0.285793  0.475609  1.0
DatagenCopulaBased.cormatgen_randFunction
cormatgen_rand(n::Int = 20)

Returns symmetric correlation matrix Σ of size n x n. Method:

a = rand(n,n)
b = a*a'
diagb = Matrix(Diagonal(1 ./sqrt.(LinearAlgebra.diag(b))))
b = diagb*b*diagb

In general gives higher correlations than the cormatgen(). Example:

julia> Random.seed!(43);

julia> cormatgen_rand(2)
2×2 Array{Float64,2}:
1.0       0.879086
0.879086  1.0
DatagenCopulaBased.cormatgen_toeplitzMethod
cormatgen_toeplitz(n::Int, ρ::Real)

Returns the correlation matrix of size n x n of the Toeplitz structure with maximal correlation equal to ρ.

julia> cormatgen_toeplitz(5, 0.9)
5×5 Array{Float64,2}:
1.0     0.9    0.81  0.729  0.6561
0.9     1.0    0.9   0.81   0.729
0.81    0.9    1.0   0.9    0.81
0.729   0.81   0.9   1.0    0.9
0.6561  0.729  0.81  0.9    1.0

julia> cormatgen_toeplitz(5, 0.6)
5×5 Array{Float64,2}:
1.0     0.6    0.36  0.216  0.1296
0.6     1.0    0.6   0.36   0.216
0.36    0.6    1.0   0.6    0.36
0.216   0.36   0.6   1.0    0.6
0.1296  0.216  0.36  0.6    1.0
DatagenCopulaBased.cormatgen_toeplitz_noisedMethod
cormatgen_toeplitz_noised(n::Int, ρ::Real; ϵ=(1-ρ)/(1+ρ)/2)

Returns the correlation matrix of size n x n of the Toeplitz structure with maximal correlation equal to ρ. Additiona noise id added by the ϵ parameter.

julia> Random.seed!(43);

julia> cormatgen_toeplitz_noised(5, 0.9)
5×5 Array{Float64,2}:
1.0       0.89656   0.812152  0.720547  0.64318
0.89656   1.0       0.918136  0.832571  0.734564
0.812152  0.918136  1.0       0.915888  0.822804
0.720547  0.832571  0.915888  1.0       0.903819
0.64318   0.734564  0.822804  0.903819  1.0
DatagenCopulaBased.cormatgen_two_constantMethod
cormatgen_two_constant(n::Int, α::Real, β::Real)

Returns the correlation matrix of size n x n of correlations determined by two constants, first must be greater than the second.

julia> cormatgen_two_constant(6, 0.5, 0.1)
6×6 Array{Float64,2}:
1.0  0.5  0.5  0.1  0.1  0.1
0.5  1.0  0.5  0.1  0.1  0.1
0.5  0.5  1.0  0.1  0.1  0.1
0.1  0.1  0.1  1.0  0.1  0.1
0.1  0.1  0.1  0.1  1.0  0.1
0.1  0.1  0.1  0.1  0.1  1.0

julia> cormatgen_two_constant(4, 0.5, 0.1)
4×4 Array{Float64,2}:
1.0  0.5  0.1  0.1
0.5  1.0  0.1  0.1
0.1  0.1  1.0  0.1
0.1  0.1  0.1  1.0
DatagenCopulaBased.cormatgen_two_constant_noisedMethod
cormatgen_two_constant_noised(n::Int, α::Real, β::Real; ϵ::Real= (1-α)/2)

Returns the correlation matrix of size n x n of correlations determined by two constants, first must be greater than the second. Additional noise is introduced by the parameter ϵ.

julia> Random.seed!(43);

julia> cormatgen_two_constant_noised(4, 0.5, 0.1)
4×4 Array{Float64,2}:
1.0         0.314724   0.190368  -0.0530078
0.314724    1.0       -0.085744   0.112183
0.190368   -0.085744   1.0        0.138089
-0.0530078   0.112183   0.138089   1.0
DatagenCopulaBased.elInvlaFMethod

elInvlaF(θ₁, θ₀, logseriescdf; rng::AbstractRNG)

Returns Int, a single sample of the inverse Laplace transform of the generator of nested Frank copula

DatagenCopulaBased.fncopulagenMethod

fncopulagen(α::Vector{Real}, β::Vector{Real}, u::Matrix{Real})


julia> fncopulagen(2, [0.2, 0.4], [0.1, 0.1], [0.2 0.4 0.6; 0.3 0.5 0.7])
2×3 Array{Float64,2}:
0.6  0.4  0.2
0.7  0.5  0.3

DatagenCopulaBased.frank_genMethod
frank_gen(r::Vector{Real}, θ::Real, logseries::Vector{Real})

Given a vector of random numbers r of size n+1, return the sample from the Frank copula parametrised by θ of the size n. Axiliary logseries is a vector of the logseries sequence priorly computed.

DatagenCopulaBased.frechetMethod

frechet(t::Int, n::Int, α::Real; rng::AbstractRNG)

Given n-variate random data u ∈ R^{t, n} Returns t realization of n variate data generated from one parameter FrechetCopula(n, α).

julia> Random.seed!(43);

julia> u = rand(10, 2);

julia> frechet(0.5, u)
10×2 Array{Real,2}:
0.180975   0.661781
0.0742681  0.0742681
0.888934   0.125437
0.0950087  0.0950087
0.130474   0.130474
0.912603   0.740184
0.828727   0.00463791
0.400537   0.0288987
0.521601   0.521601
0.955881   0.851275
DatagenCopulaBased.frechet_el!Method

frechet_el!(u::Vector{Real}, α::Real, v::Real)

Given n-variate random vector changes it to such modeled by the two parameters FrechetCopula(n, α, β). v is the random number form [0,1].

DatagenCopulaBased.frechet_el2!Method

function frechet_el2!(u::Vector{Real}, α::Real, β::Real, v::Real)

Given bivariate random vector changes it to such modeled by the two parameters FrechetCopula(n, α, β). v is the random number form [0,1]

DatagenCopulaBased.gcop2archMethod
gcop2arch(x::Matrix{Real}, inds::Vector{Pair{String,Vector{Int64}}}; naive::Bool = false, notnested::Bool = false, rng = Random.GLOBAL_RNG)

Takes x the matrix of t realizations of data from Gaussian n-variate distribution. Return a matrix of size x, where chosen subset of marginals (inds[i][2]) has an Archimedean sub-copula (denoted by inds[i][1]), all univariate marginals are unchanged.

For example inds = ["clayton" => [1,2]] means that the subset of marginals indexed by 1,2 will be changed to the Clayton sub-copula. Inds may have more elements but marginals must not overlap.

If naive, the naive resampling will be used. In notnested nested Archimedean copulas will not be used.


julia> Σ = [1. 0.5 0.5; 0.5 1. 0.5; 0.5 0.5 1];

julia> Random.seed!(42)

julia> x = rand(MvNormal(Σ), 6)'
6×3 Array{Float64,2}:
-0.556027  -0.662861   -0.384124
-0.299484   1.38993    -0.571326
-0.468606  -0.0990787  -2.3464
1.00331    1.43902     0.966819
0.518149   1.55065     0.989712
-0.886205   0.149748   -1.54419

julia> gcop2arch(x, ["clayton" => [1,2]]; naive::Bool = false, notnested::Bool = false)
6×3 Array{Float64,2}:
-0.742443   0.424851  -0.384124
0.211894   0.195774  -0.571326
-0.989417  -0.299369  -2.3464
0.157683   1.47768    0.966819
0.154893   0.893253   0.989712
-0.657297  -0.339814  -1.54419
DatagenCopulaBased.gcop2frechetMethod
gcop2frechet(x::Matrix{Real}, inds::Vector{Int}; naive::Bool = false, rng = Random.GLOBAL_RNG)

Takes x the matrix of t realizations of data from the Gaussian n-variate distribution.

Return the matrix of size x, where chosen subset of marginals (determined by inds) has the Frechet (one parameter) sub-copula, all univariate marginals are unchanged. If naive, performs the naive resampling.


julia> Σ = [1. 0.5 0.5; 0.5 1. 0.5; 0.5 0.5 1];

julia> Random.seed!(42)

julia> x = rand(MvNormal(Σ), 6)'
6×3 Array{Float64,2}:
-0.556027  -0.662861   -0.384124
-0.299484   1.38993    -0.571326
-0.468606  -0.0990787  -2.3464
1.00331    1.43902     0.966819
0.518149   1.55065     0.989712
-0.886205   0.149748   -1.54419

julia> gcop2frechet(x, [1,2])
6×3 Array{Float64,2}:
-0.875777   -0.374723   -0.384124
0.0960334   0.905703   -0.571326
-0.599792   -0.0110945  -2.3464
0.813717    1.8513      0.966819
0.599255    1.56873     0.989712
-0.7223     -0.172507   -1.54419
DatagenCopulaBased.gcop2marshallolkinFunction
gcop2marshallolkin(x::Matrix{Real}, inds::Vector{Int}, λ1::Real = 1., λ2::Real = 1.5; naive::Bool = false, rng = Random.GLOBAL_RNG)

Takes x the matrix of t realizations of data from Gaussian n-variate distribution.

Return a matrix of size x, where chosen subset of marginals (inds) has bi-variate Marshall-Olkin sub-copula parameterized by the free parameters λ1 and λ2. λ12 is computed form the correlation between marginals. All univariate marginals are unchanged. If naive, uses the naive resampling.


julia> Σ = [1. 0.5 0.5; 0.5 1. 0.5; 0.5 0.5 1];

julia> Random.seed!(42)

julia> x = rand(MvNormal(Σ), 6)'
6×3 Array{Float64,2}:
-0.556027  -0.662861   -0.384124
-0.299484   1.38993    -0.571326
-0.468606  -0.0990787  -2.3464
1.00331    1.43902     0.966819
0.518149   1.55065     0.989712
-0.886205   0.149748   -1.54419

julia> gcop2marshallolkin(x, [1,2], 1., 1.5; naive = false)
6×3 Array{Float64,2}:
-0.790756   0.784371  -0.384124
-0.28088    0.338086  -0.571326
-0.90688   -0.509684  -2.3464
0.738628   1.71026    0.966819
0.353654   1.19357    0.989712
-0.867606  -0.589929  -1.54419
DatagenCopulaBased.gcop2tstudentMethod
gcop2tstudent(x::Matrix{Real}, ind::Vector{Int}, ν::Int; naive::Bool = false)

Takes x the matrix of t realizations of data from Gaussian n-variate distribution.

Return the matrix of size x, where chosen subset of marginals (indexed by ind) has the t-Student copula with ν degrees of freedom, all univariate marginals are unchanged. If naive, performs the naive resampling.


julia> Σ = [1. 0.5 0.5; 0.5 1. 0.5; 0.5 0.5 1];

julia> Random.seed!(42)

julia> x = rand(MvNormal(Σ), 6)'
6×3 Array{Float64,2}:
-0.556027  -0.662861   -0.384124
-0.299484   1.38993    -0.571326
-0.468606  -0.0990787  -2.3464
1.00331    1.43902     0.966819
0.518149   1.55065     0.989712
-0.886205   0.149748   -1.54419

julia> gcop2tstudent(x, [1,2], 6)
6×3 Array{Float64,2}:
-0.514449  -0.49147    -0.384124
-0.377933   1.66254    -0.571326
-0.430426  -0.0165044  -2.3464
0.928668   1.50472     0.966819
0.223439   1.12372     0.989712
-0.710786   0.239012   -1.54419
DatagenCopulaBased.getθ4archMethod
getθ4archgetθ4arch(ρ::Real, copula::String, cor::Type{SpearmanCorrelation})

getθ4archgetθ4arch(ρ::Real, copula::String, cor::Type{KendallCorrelation})

Compute the copula parameter given the correlation, test if the parameter is in range. Following types are supported: SpearmanCorrelation, KendallCorrelation


julia> getθ4arch(0.5, "gumbel", SpearmanCorrelation)
1.541070420842913

julia> getθ4arch(0.5, "gumbel", KendallCorrelation)
2.0
DatagenCopulaBased.gumbel_genMethod
  gumbel_gen(r::Vector{Real}, θ::Real)

Given a vector of random numbers r of size n+2, return the sample from the Gumbel copula parametrised by θ of the size n.

DatagenCopulaBased.levyelMethod
levyel(θ, u1, u2)

u1 and u2 are supposed to be random numbers form [0,1] An element from Levy stable distribution with parameters α = 1/θ, β = 1, γ = (cos(pi/(2*θ)))^θ and δ = 0.

DatagenCopulaBased.meanΣMethod

meanΣ(Σ::Matrix{Real})

Returns Real, a mean of the mean of lower diagal elements of a matrix


julia> s= [1. 0.2 0.3; 0.2 1. 0.4; 0.3 0.4 1.];

julia> meanΣ(s)
0.3
DatagenCopulaBased.mocopulaMethod

mocopula(u::Matrix{Real}, n::Int, λ::Vector{Real})

Returns: t x n Matrix{Float}, t realizations of n-variate data generated from Marshall-Olkin copula with parameter vector λ of non-negative elements λₛ, given [0,1]ᵗˣˡ ∋ u, where l = 2ⁿ-1


julia> mocopula([0.2 0.3 0.4; 0.3 0.4 0.6; 0.4 0.5 0.7], 2, [1., 1.5, 2.])
3×2 Array{Float64,2}:
0.252982  0.201189
0.464758  0.409039
0.585662  0.5357

DatagenCopulaBased.mocopula_elMethod
mocopula_el(u::Vector{Real}, n::Int, λ::Vector{Real}, s::Vector{Vector{Int}})

julia> mocopula_el([0.1, 0.2, 0.3], 2, [1., 2., 3.], s)
2-element Array{Float64,1}:
0.20082988502465082
0.1344421423967149
DatagenCopulaBased.nested_frank_genMethod
nested_frank_gen(n::Vector{Vector{Int}}, ϕ::Vector{Real}, θ::Real, rand_vec::Vector{Real}, logseries::Vector{Real},
logseries_children::Vector{Vector{Real}};
rng::AbstractRNG)
DatagenCopulaBased.nested_gumbel_genMethod
nested_gumbel_gen(n::Vector{Vector{Int}}, ϕ::Vector{Real},
θ::Real, rand_vec::Vector{Real}; rng::AbstractRNG)

Convert a vector of random independnet elements to such sampled from the Nested Gumbel copula

DatagenCopulaBased.nestedcopulagMethod

nestedcopulag(copula::String, ns::Vector{Vector{Int}}, ϕ::Vector{Real}, θ::Real, r::Matrix{Real})

Given [0,1]ᵗˣˡ ∋ r, returns t realizations of l-1 variate data from nested archimedean copula

julia> Random.seed!(43)

julia> nestedcopulag("clayton", [[1,2],[3,4]], [2., 3.], 1.1, [0.1 0.2 0.3 0.4 0.5; 0.2 0.3 0.4 0.5 0.6])
julia> nestedcopulag("clayton", [[1,2],[3,4]], [2., 3.], 1.1, [0.1 0.2 0.3 0.4 0.5; 0.2 0.3 0.4 0.5 0.6])
2×4 Array{Float64,2}:
0.153282  0.182421  0.374228  0.407663
0.69035   0.740927  0.254842  0.279192
DatagenCopulaBased.nestedfrankgenMethod

nestedfrankgen(θ₁, θ₀, V0::Int, logseriescdf; rng::AbstractRNG)

Return int, sampled from the Inverse Laplace trensform of nested Frank copula given parametes θ₁ θ₀ (child and parent) and an element of V0 - vector of samples of invlaplace of the parents copula

DatagenCopulaBased.parametersMethod
parameters(x::Matrix{Real}, part::Vector{Vector{Int}})

Returns parametrization by correlation for data x and partition part for nested copulas.

DatagenCopulaBased.rand2copMethod

rand2cop(u1::Real, θ::Real, copula::String, w::Real)

Returns Real generated using copula::String given u1 and w from uniform distribution and copula parameter θ.

DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::AmhCopulaRev; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the reversed Ali-Mikhail-Haq copula a - AmhCopulaRev(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> Random.seed!(43);

julia> U = zeros(4,2)
4×2 Array{Float64,2}:
0.0  0.0
0.0  0.0
0.0  0.0
0.0  0.0

julia> simulate_copula!(U, AmhCopulaRev(2, 0.5))

julia> U
4×2 Array{Float64,2}:
0.516061   0.116089
0.0379356  0.334231
0.292457   0.74958
0.0845089  0.505477
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::AmhCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the Ali-Mikhail-Haq copula- AmhCopula(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> Random.seed!(43);

julia> simulate_copula!(U, AmhCopula(2, -0.5))

julia> U
4×2 Array{Float64,2}:
0.180975  0.820073
0.888934  0.886169
0.408278  0.919572
0.828727  0.335864
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::ChainArchimedeanCopulas; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, returns size(U,1) realizations of data modeled by the chain of bivariate Archimedean copulas. N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> c = ChainArchimedeanCopulas([4., 11.], "frank")
ChainArchimedeanCopulas(3, [4.0, 11.0], ["frank", "frank"])

julia> u = zeros(1,3)
1×3 Array{Float64,2}:
0.0  0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(u,c)

julia> u
1×3 Array{Float64,2}:
0.180975  0.492923  0.679345

julia> u = zeros(1,3)
1×3 Array{Float64,2}:
0.0  0.0  0.0

julia> Random.seed!(43);

julia> c = ChainArchimedeanCopulas([.5, .7], ["frank", "clayton"], KendallCorrelation)
ChainArchimedeanCopulas(3, [5.736282707019972, 4.666666666666666], ["frank", "clayton"])

julia> simulate_copula!(u,c)

julia> u
1×3 Array{Float64,2}:
0.180975  0.408582  0.646887
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::ClaytonCopulaRev; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the reversed Clayton copula - ClaytonCopulaRev(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> Random.seed!(43);

julia> U = zeros(2,2)
2×2 Array{Float64,2}:
0.0  0.0
0.0  0.0

julia> simulate_copula!(U, ClaytonCopulaRev(2, -0.5))

julia> U
2×2 Array{Float64,2}:
0.819025  0.181983
0.111066  0.136642

julia> Random.seed!(43);

julia> U = zeros(2,2)
2×2 Array{Float64,2}:
0.0  0.0
0.0  0.0

julia> simulate_copula!(U, ClaytonCopulaRev(2, 2.))

julia> U
2×2 Array{Float64,2}:
0.347188   0.087281
0.0257036  0.212676
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::ClaytonCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns t realizations from the Clayton copula - ClaytonCopula(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n. N.o. realisations is size(U,1).

julia> Random.seed!(43);

julia> U = zeros(3,2)
3×2 Array{Float64,2}:
0.0  0.0
0.0  0.0
0.0  0.0

julia> simulate_copula!(U, ClaytonCopula(2, 1.))

julia> U
3×2 Array{Float64,2}:
0.562482  0.896247
0.968953  0.731239
0.749178  0.38015

julia> U = zeros(2,2)
2×2 Array{Float64,2}:
0.0  0.0
0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(U, ClaytonCopula(2, -.5))

julia> U
2×2 Array{Float64,2}:
0.180975  0.818017
0.888934  0.863358
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::FrankCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the Frank copula- FrankCopula(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> U = zeros(4,2)
4×2 Array{Float64,2}:
0.0  0.0
0.0  0.0
0.0  0.0
0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(U, FrankCopula(2, 3.5))

julia> U
4×2 Array{Float64,2}:
0.650276  0.910212
0.973726  0.789701
0.690966  0.358523
0.747862  0.29333
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::FrechetCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the Frechet copula - FrechetCopula N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> f = FrechetCopula(3, 0.5)
FrechetCopula(3, 0.5, 0.0)

julia> u = zeros(1,3)
1×3 Array{Real,2}:
0.0  0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(u,f)

julia> u
1×3 Array{Real,2}:
0.180975  0.775377  0.888934
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::GumbelCopulaRev; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the reversed Gumbel copula - GumbelCopulaRev(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> Random.seed!(43);

julia> U = zeros(2,3)
2×3 Array{Float64,2}:
0.0  0.0  0.0
0.0  0.0  0.0

julia> simulate_copula!(U, GumbelCopulaRev(3, 1.5))

julia> U
2×3 Array{Flaot64,2}:
0.259962  0.081072  0.0493259
0.362174  0.516486  0.876051
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::GumbelCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the Gumbel copula - GumbelCopula(n, θ) N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> Random.seed!(43);

julia> U = zeros(2,3)
2×3 Array{Float64,2}:
0.0  0.0  0.0
0.0  0.0  0.0

julia> simulate_copula!(U, GumbelCopula(3, 1.5))

julia> U
2×3 Array{Float64,2}:
0.740038  0.918928  0.950674
0.637826  0.483514  0.123949
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::HierarchicalGumbelCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the hierachically nested Gumbel copula - HierarchicalGumbelCopula N.o. marginals is size(U,2), these must be euqal to n.o. marginals of the copula i.e. copula.n


julia> c = HierarchicalGumbelCopula([5., 4., 3.])
HierarchicalGumbelCopula(4, [5.0, 4.0, 3.0])

julia> Random.seed!(43);

julia> u = zeros(3,4)
3×4 Array{Float64,2}:
0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0

julia> simulate_copula!(u, c)

julia> u
3×4 Array{Float64,2}:
0.100353  0.207903  0.0988337  0.0431565
0.347417  0.217052  0.223734   0.042903
0.73617   0.347349  0.168348   0.410963
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::MarshallOlkinCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the Marshall Olkin copula - MarshallOlkinCopula N.o. marginals is size(U,2), requires size(U,2) == copula.n

julia> u = zeros(1,2)
1×2 Array{Float64,2}:
0.0  0.0

julia> cop = MarshallOlkinCopula([1.,2.,3.])
MarshallOlkinCopula(2, [1.0, 2.0, 3.0])

julia> Random.seed!(43);

julia> simulate_copula!(u,cop)

julia> u
1×2 Array{Float64,2}:
0.854724  0.821831
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::NestedAmhCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the nested AMH copula - NestedAmhCopula N.o. marginals is size(U,2), these must be euqal to n.o. marginals of the copula


julia> c1 = AmhCopula(2, .7)
AmhCopula(2, 0.7)

julia> c2 = AmhCopula(2, .8)
AmhCopula(2, 0.8)

julia> cp = NestedAmhCopula([c1, c2], 1, 0.2)
NestedAmhCopula(AmhCopula[AmhCopula(2, 0.7), AmhCopula(2, 0.8)], 1, 0.2)

julia> Random.seed!(43);

julia> U = zeros(4,5)
4×5 Array{Float64,2}:
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0

julia> simulate_copula!(U, cp)

julia> U
4×5 Array{Float64,2}:
0.557393  0.902767  0.909853  0.938522  0.586068
0.184204  0.866664  0.699134  0.226744  0.102932
0.268634  0.383355  0.179023  0.533749  0.995958
0.578143  0.840169  0.743728  0.963226  0.576695
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::NestedClaytonCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the nested Clayton copula - NestedClaytonCopula N.o. marginals is size(U,2), these must be euqal to n.o. marginals of the copula


julia> c1 = ClaytonCopula(2, 2.)
ClaytonCopula(2, 2.0)

julia> c2 = ClaytonCopula(2, 3.)
ClaytonCopula(2, 3.0)

julia> cp = NestedClaytonCopula([c1, c2], 1, 1.1)
NestedClaytonCopula(ClaytonCopula[ClaytonCopula(2, 2.0), ClaytonCopula(2, 3.0)], 1, 1.1)

julia> U = zeros(5,5)
5×5 Array{Float64,2}:
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(U, cp)

julia> U
5×5 Array{Float64,2}:
0.514118  0.84089    0.870106   0.906233  0.739349
0.588245  0.85816    0.935308   0.944444  0.709009
0.59625   0.665947   0.483649   0.603074  0.153501
0.200051  0.304099   0.242572   0.177836  0.0851603
0.120914  0.0683055  0.0586907  0.126257  0.519241
DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::NestedFrankCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the nested Frank copula a - NestedFrankCopula N.o. marginals is size(U,2), these must be euqal to n.o. marginals of the copula


julia> c1 = FrankCopula(2, 4.)
FrankCopula(2, 4.0)

julia> c2 = FrankCopula(2, 5.)
FrankCopula(2, 5.0)

julia> c = NestedFrankCopula([c1, c2],1, 2.0)
NestedFrankCopula(FrankCopula[FrankCopula(2, 4.0), FrankCopula(2, 5.0)], 1, 2.0)

julia> U = zeros(1,5)
1×5 Array{Float64,2}:
0.0  0.0  0.0  0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(U, c)

julia> U
1×5 Array{Float64,2}:
0.642765  0.901183  0.969422  0.9792  0.74155

DatagenCopulaBased.simulate_copula!Method
simulate_copula!(U::Matrix{Real}, copula::NestedGumbelCopula; rng::AbstractRNG = Random.GLOBAL_RNG)

Given the preallocated output U, Returns size(U,1) realizations from the nested Gumbel copula - NestedGumbelCopula N.o. marginals is size(U,2), these must be euqal to n.o. marginals of the copula

julia> c1 = GumbelCopula(2, 2.)
GumbelCopula(2, 2.0)

julia> c2 = GumbelCopula(2, 3.)
GumbelCopula(2, 3.0)

julia> cp = NestedGumbelCopula([c1, c2], 1, 1.1)
NestedGumbelCopula(GumbelCopula[GumbelCopula(2, 2.0), GumbelCopula(2, 3.0)], 1, 1.1)

julia> u = zeros(4,5)
4×5 Array{Float64,2}:
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0

julia> Random.seed!(43);

julia> simulate_copula!(u, cp)

julia> u
4×5 Array{Float64,2}:
0.387085   0.693399   0.94718   0.953776  0.583379
0.0646972  0.0865914  0.990691  0.991127  0.718803
0.966896   0.709233   0.788019  0.855622  0.755476
0.272487   0.106996   0.756052  0.834068  0.661432
DatagenCopulaBased.testbivθMethod

testbivθ(θ::Union{Real}, copula::String)

Tests bivariate copula parameter

clayton bivariate sub-copulas with parameters (θᵢ ≥ -1) ^ ∧ (θᵢ ≠ 0). amh – Ali-Mikhail-Haq bi-variate sub-copulas with parameters -1 ≥ θᵢ ≥ 1 Frank bi-variate sub-copulas with parameters (θᵢ ≠ 0)

DatagenCopulaBased.tiltedlevygenMethod
tiltedlevygen(V0, α; rng::AbstractRNG)

Returns a sample from the expotencialy tilted Levy stable pdf f(x; V0, α) = exp(-V0^α) g(x; α)/exp(-V0), where g(x; α) is a stable Levy pdf with parameters α = 1/θ, β = 1, γ = (cos(pi/(2*θ)))^θ and δ = 0.

DatagenCopulaBased.usebivρMethod
usebivρ(ρ::Real, copula::String, cor::Type{<:CorrelationType})

Returns Real, a copula parameter given the Spearman or the Kendall correlation

For Clayton or Frank copula the correlation must fulfill (-1 > ρᵢ > 1) ∧ (ρᵢ ≠ 0) For the AMH copula Spearman must fulfill -0.2816 > ρᵢ >= .5, while Kendall -0.18 < τ < 1/3

DatagenCopulaBased.useρMethod

useρ(ρ::Real, copula::String)

Tests the available Spearman correlation for the Archimedean copula.

Returns Real, the copula parameter θ with the Spearman correlation ρ.


julia> useρ(0.75, "gumbel")
2.294053859606698
DatagenCopulaBased.useτMethod

useτ(ρ::Real, copula::String)

Tests the available kendall's correlation for archimedean copula, returns Float, corresponding copula parameter θ.


julia> useτ(0.5, "clayton")
2.0
DatagenCopulaBased.Σ_theorMethod

Σ_theor(ϕ::Vector{Real}, θ::Real, part::Vector{Vector{Int}})

returns a matrix indicating a theoretical correlation according togiven parameters and partition

DatagenCopulaBased.τ2λMethod

τ2λ(τ::Vector{Real}, λ::Vector{Real})

Suplement the vector of λ patrameters of Marshall-Olkin copula, given some of those parameters and a vector fo Kendall's τ correlations. Wroks fo 2,3 variate MO copula