pycop icon indicating copy to clipboard operation
pycop copied to clipboard

Issue with the empirical copula

Open ErikVanem opened this issue 8 months ago • 0 comments

I want to evaluate the empirical copula, and I get some issues. For example, the CDF of (0, 0) returns 1.0. This must obviously be a bug?? Please help.

I have pseudo-observations in a dataframe uv

uv = pd.DataFrame({'u1':u1, 'u2':u2})

Then I generate the empirical copula

import pycop as cop
C_emp = cop.empirical(uv.T.values)

To get the CDF for a new point, I call

C_emp.get_cdf()

Is this not correct?? Why do I get CDF = 1.0 for input (0, 0) (and some other very small numbers).

C_emp.get_cdf(0, 0)
Out[1096]: 1.0

It seems to work OK for larger numbers, but not for the very small ones. If I use the minimum values in the dataset. I get 0.0

C_emp.get_cdf(uv.min()[0], uv.min()[1])
Out[1107]: 0.0

But for some values less that this, I start getting non-zero values. This seems to be not correct, or am I using this incorrectly? I would appreciate some help.

C_emp.get_cdf(uv.min()[0]-1.e-7, uv.min()[1]-1.e-7)
Out[1114]: 0.0

C_emp.get_cdf(uv.min()[0]-1.e-6, uv.min()[1]-1.e-6)
Out[1113]: 0.0020763493551039184

C_emp.get_cdf(uv.min()[0]-1.e-4, uv.min()[1]-1.e-4)
Out[1111]: 0.0020763493551039184

C_emp.get_cdf(uv.min()[0]-1.e-3, uv.min()[1]-1.e-3)
Out[1109]: 0.0020763493551039184

C_emp.get_cdf(uv.min()[0]-1.e-2, uv.min()[1]-1.e-2)
Out[1108]: 0.985872742786007

C_emp.get_cdf(uv.min()[0]-1.e-1, uv.min()[1]-1.e-1)
Out[1110]: 0.8632049446954403

Playing around with some very small values (they should all give empirical CDF = 0?

C_emp.get_cdf(1.e-7, 1.e-7)
Out[1115]: 1.0

C_emp.get_cdf(1.e-6, 1.e-6)
Out[1116]: 0.0

C_emp.get_cdf(1.e-8, 1.e-8)
Out[1117]: 1.0

C_emp.get_cdf(1.e-8, 1.e-6)
Out[1118]: 1.5541537089101186e-06

C_emp.get_cdf(1.e-7, 1.e-6)
Out[1119]: 1.5541537089101186e-06

C_emp.get_cdf(1.e-6, 1.e-6)
Out[1120]: 0.0

C_emp.get_cdf(1.e-6, 1.e-7)
Out[1121]: 0.0020763493551039184

ErikVanem avatar Mar 26 '25 08:03 ErikVanem