Skip to content

Commit

Permalink
most of new dispatching for archimedean copulas
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Apr 20, 2020
1 parent 758f097 commit 3ca7c99
Show file tree
Hide file tree
Showing 8 changed files with 598 additions and 204 deletions.
6 changes: 4 additions & 2 deletions src/DatagenCopulaBased.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ module DatagenCopulaBased
# change Gaussian data by adding higher order cross-correlations
include("add_higher_order_cors.jl")

export gaussian_cop, tstudent_cop, frechet, marshallolkin, gumbel, clayton, amh, frank
export rev_gumbel, rev_clayton, rev_amh
export clayton, amh, frank
export rev_clayton, rev_amh

export Gaussian_cop, Student_cop, Frechet_cop, Marshall_Olkin_cop
export Gumbel_cop, Gumbel_cop_rev, Clayton_cop, Clayton_cop_rev, AMH_cop, AMH_cop_rev
export archcopulagen, chaincopulagen, nestedarchcopulagen
export cormatgen, cormatgen_constant, cormatgen_toeplitz, convertmarg!, gcop2arch
export cormatgen_constant_noised, cormatgen_toeplitz_noised, cormatgen_rand
Expand Down
18 changes: 1 addition & 17 deletions src/add_higher_order_cors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function gcop2tstudent(x::Matrix{Float64}, ind::Vector{Int}, ν::Int; naive::Boo
μ = mean(x, dims = 1)
y = (y.-μ)./S
if naive
z = tstudent_cop(size(x,1), cor(x[:,ind]), ν)
z = simulate_copula1(size(x,1), Student_cop(cor(x[:,ind]), ν))
y[:,ind] = quantile.(Normal(0,1), z)
else
U = rand(Chisq(ν), size(x, 1))
Expand Down Expand Up @@ -163,22 +163,6 @@ function gcop2frechet(x::Matrix{Float64}, inds::Vector{Int}; naive::Bool = false
quantile.(Normal(0,1), x).*S.+μ
end

"""
frechet(α::Float64, u::Matrix{Float64})
returns a matrix of size u with data generated using Frechet maximal copula with
parameter α
"""
function frechet::Float64, u::Matrix{Float64})
for j in 1:size(u, 1)
if (rand() < α)
for i in 1:size(u,2)
u[j,i] = u[j, end]
end
end
end
u
end

"""
gcop2marshallolkin(x::Matrix{Float64}, inds::Vector{Int}, λ1::Float64 = 1., λ2::Float64 = 1.5; naive::Bool = false)
Expand Down

0 comments on commit 3ca7c99

Please sign in to comment.