CDF of a copula from Copulas.jl?

The lower-bound problem may depend on how we define the copula function. The following is my understanding. Consider a bivariate joint distribution constructed by a copula function:

H_\rho(x, y) = C_\rho(\Phi_x(x), \Phi_y(y))

where H_\rho() is the joint distribution function, C_\rho() is the copula, \Phi_x(.) is the CDF of the marginal distribution of x; similar for \Phi_y(.).

In the case where both x and y have normal marginal distributions, we have x\in (-\infty, \infty) and y\in (-\infty, \infty) while both \Phi_x(\cdot) and \Phi_y(\cdot) are uniformally distributed in (0,1).

So, whether the lower bounds in the code should be -\infty or 0, may depend on whether the model is constructed on (x, y) or (\Phi_x(x), \Phi_y(y)).

Using the code example in my previous post, the joint distribution is constructed by D1 = SklarDist(C1, (x,y)) which, I believe, would have x and y as inputs to D1 (i.e., D1 is akin to H_\rho(x,y)). Therefore, when doing integration on D1, I think the lower bounds should be those of (x,y), i.e., -\infty.

Does it make sense?

ps. Now I think I understand your comment: You want the joint distribution to be represented by C_\rho(\Phi_x(x), \Phi_y(y)) where the arguments are defined by (\Phi_x(), \Phi_y()). I am not sure whether this is a good idea for many empirical researchers. Many times our data is in the form of x (e.g., log of the class scores) but not \Phi_x(). We want to input (x, y) and get the pdf, cdf, and the likelihood value of the distribution. This may be a case where good notations and practical uses are in conflict.

(edit to add the last paragraph)

The problem is definitely not with the endpoints, but rather with my algorithm for computing the gaussian copula’s cdf, EDIT: which was completely wrong.

One more thing I found.
cdf calculation can be very unstable for hcubature / pcubature when the covariance matrix is ill-conditioned.

You can check with this:

sigm = [0.0013865355202741095 -0.023165016749546796; -0.023165016749546796 0.7991000945648858]
ll=  [-1.961458153653283, -0.5364265399377888]
ul=[1.3629503813703872, 0.9163988499775846]

and compare HCubature, MonteCarloIntegration, MvNormalCDF

julia> vegas(x->pdf(MvNormal([0.0013865355202741095 -0.023165016749546796; -0.023165016749546796 0.7991000945648858]), x), [-1.961458153653283, -0.5364265399377888], [1.3629503813703872, 0.9163988499775846])
nevals = 100000
(0.5757244529231219, 0.0026735571093816387, 1.1996526761564548)

julia> MvNormalCDF.mvnormcdf(MvNormal([0.0013865355202741095 -0.023165016749546796; -0.023165016749546796 0.7991000945648858]), [-1.961458153653283, -0.5364265399377888], [1.3629503813703872, 0.9163988499775846])
(0.5731256346884859, 0.0)

julia> hcubature(x->pdf(MvNormal([0.0013865355202741095 -0.023165016749546796; -0.023165016749546796 0.7991000945648858]), x), [-1.961458153653283, -0.5364265399377888], [1.3629503813703872, 0.9163988499775846])
(0.11536400241722981, 1.6726225814742802e-9)
2 Likes

I settled for the dependency on MvNormalCDF after reading the article from Alan Genz and understanding my previous mistakes…

@HJW019 : Should work on Copulas 0.1.6 (once registered), thanks again for the catch.

1 Like

Great! Thanks a lot.