Skip to content

Commit

Permalink
Formalize Kendall's tau (#225)
Browse files Browse the repository at this point in the history
* docs(dependence_measures): Improve explanations and implement interfaces for obtaining Kendall's tau and Spearman's Rho.

* feat: Added functions to calculate bivariate Kendall taus and Spearman rhos.

* feat: Add corkendall function to EmpiricalCopula in fit method
  • Loading branch information
lrnv authored Sep 21, 2024
1 parent c1d47d7 commit b95a118
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions docs/src/assets/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -864,4 +864,14 @@ @incollection{lindskog2003kendall
pages={149--156},
year={2003},
publisher={Springer}
}
@article{blier2022stochastic,
title={Stochastic representation of FGM copulas using multivariate Bernoulli random variables},
author={Blier-Wong, Christopher and Cossette, H{\'e}l{\`e}ne and Marceau, Etienne},
journal={Computational Statistics \& Data Analysis},
volume={173},
pages={107506},
year={2022},
publisher={Elsevier}
}
14 changes: 8 additions & 6 deletions src/Copula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ function τ(C::Copula)
end
function StatsBase.corkendall(C::Copula{d}) where d
# returns the matrix of bivariate kendall taus.
K = zeros(d,d)
K = ones(d,d)
for i in 1:d
for j in 1:d
K[i,j] = i==j ? 1 : τ(SubsetCopula(C::Copula{d},(i,j)))
for j in i+1:d
K[i,j] = τ(SubsetCopula(C::Copula{d},(i,j)))
K[j,i] = K[i,j]
end
end
return K
end
function StatsBase.corspearman(C::Copula{d}) where d
# returns the matrix of bivariate spearman rhos.
K = zeros(d,d)
K = ones(d,d)
for i in 1:d
for j in 1:d
K[i,j] = i==j ? 1 : ρ(SubsetCopula(C::Copula{d},(i,j)))
for j in i+1:d
K[i,j] = ρ(SubsetCopula(C::Copula{d},(i,j)))
K[j,i] = K[i,j]
end
end
return K
Expand Down
2 changes: 1 addition & 1 deletion src/MiscellaneousCopulas/EmpiricalCopula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ end
function Distributions.fit(::Type{CT},u) where {CT <: EmpiricalCopula}
return EmpiricalCopula(u)
end
StatsBase.corkendall(C::EmpiricalCopula) = StatsBase.corkendall(C.u)
StatsBase.corkendall(C::EmpiricalCopula) = StatsBase.corkendall(C.u')

0 comments on commit b95a118

Please sign in to comment.