The Kendall function is an important function in dependence structure analysis. The Kendall function associated with a
From a computational point of view, we often do not access to true observations of the random vector
Indeed,
struct KendallFunction{T}
z::Vector{T}
function KendallFunction(x)
d,n = size(x)
z = zeros(n)
for i in 1:n
for j in 1:n
if j ≠ i
z[i] += reduce(&, x[:,j] .< x[:,i])
end
end
end
z ./= (n-1)
sort!(z) # unnecessary
return new{eltype(z)}(z)
end
end
function (K::KendallFunction)(t)
# Then the K function is simply the empirical cdf of the Z sample:
return sum(K.z .≤ t)/length(K.z)
end
nothing # hide
Let us try it on a random example:
using Copulas, Distributions, Plots
X = SklarDist(ClaytonCopula(2,2.7),(Normal(),Pareto()))
x = rand(X,1000)
K = KendallFunction(x)
plot(u -> K(u), xlims = (0,1), title="Empirical Kendall function")
One notable detail on the Kendall function is that is does not characterize the copula in all generality. On the other hand, for an Archimedean copula with generator ϕ, we have:
Due to this partical relationship, the Kendall function actually characterizes the generator of the archimedean copula. In fact, this relationship is generally expressed in term of a λ function defined as
Common λ functions can be easily derived by hand for standard archimedean generators. For any archimedean generator in the package, however, it is even easier to let Julia do the derivation.
Let's try to compare the empirical λ function from our dataset to a few theoretical ones. For that, we setup parameters of the relevant generators to match the kendall τ of the dataset (because we can). We include for the record the independent and completely monotonous cases.
using Copulas: ϕ⁽¹⁾, ϕ⁻¹, τ⁻¹, ClaytonGenerator, GumbelGenerator
using StatsBase: corkendall
λ(G,t) = ϕ⁽¹⁾(G,ϕ⁻¹(G,t)) * ϕ⁻¹(G,t)
plot(u -> u - K(u), xlims = (0,1), label="Empirical λ function")
κ = corkendall(x')[1,2] # empirical kendall tau
θ_cl = τ⁻¹(ClaytonGenerator,κ)
θ_gb = τ⁻¹(GumbelGenerator,κ)
plot!(u -> λ(ClaytonGenerator(θ_cl),u), label="Clayton")
plot!(u -> λ(GumbelGenerator(θ_gb),u), label="Gumbel")
plot!(u -> 0, label="Comonotony")
plot!(u -> u*log(u), label="Independence")
The variance of the empirical λ function is notable on this example. In particular, we note that the estimated parameter
θ_cl
is not very far for the true
- Empirical validation of the archimedean property of the data, and then
- Non-parametric estimation of the generator from the empirical Kendall function, or through other means.
- Non-archimedean parametric models.