-
Notifications
You must be signed in to change notification settings - Fork 9
/
JoeGenerator.jl
57 lines (50 loc) · 1.84 KB
/
JoeGenerator.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
JoeGenerator{T}
Fields:
- θ::Real - parameter
Constructor
JoeGenerator(θ)
JoeCopula(d,θ)
The [Joe](https://en.wikipedia.org/wiki/Copula_(probability_theory)#Most_important_Archimedean_copulas) copula in dimension ``d`` is parameterized by ``\\theta \\in [1,\\infty)``. It is an Archimedean copula with generator :
```math
\\phi(t) = 1 - \\left(1 - e^{-t}\\right)^{\\frac{1}{\\theta}}
```
It has a few special cases:
- When θ = 1, it is the IndependentCopula
- When θ = ∞, is is the MCopula (Upper Frechet-Hoeffding bound)
References:
* [nelsen2006](@cite) Nelsen, Roger B. An introduction to copulas. Springer, 2006.
"""
struct JoeGenerator{T} <: UnivariateGenerator
θ::T
function JoeGenerator(θ)
if θ < 1
throw(ArgumentError("Theta must be greater than 1"))
elseif θ == 1
return IndependentGenerator()
elseif θ == Inf
return MGenerator()
else
return new{typeof(θ)}(θ)
end
end
end
max_monotony(G::JoeGenerator) = Inf
ϕ( G::JoeGenerator, t) = 1-(-expm1(-t))^(1/G.θ)
ϕ⁻¹(G::JoeGenerator, t) = -log1p(-(1-t)^G.θ)
# ϕ⁽¹⁾(G::JoeGenerator, t) = First derivative of ϕ
# ϕ⁽ᵏ⁾(G::JoeGenerator, k, t) = kth derivative of ϕ
τ(G::JoeGenerator) = 1 - 4sum(1/(k*(2+k*G.θ)*(G.θ*(k-1)+2)) for k in 1:1000) # 446 in R copula.
function τ⁻¹(::Type{T},tau) where T<:JoeGenerator
if tau == 1
return Inf
elseif tau == 0
return 1
elseif tau < 0
@warn "JoeCoula cannot handle negative kendall taus, we return the independence..."
return one(tau)
else
return Roots.find_zero(θ -> τ(JoeGenerator(θ)) - tau, (one(tau),tau*Inf))
end
end
williamson_dist(G::JoeGenerator, d) = WilliamsonFromFrailty(Sibuya(1/G.θ), d)