Skip to content

BUG/ENH: correct tau for small theta in FrankCopula - #8662

Merged
josef-pkt merged 1 commit into
statsmodels:mainfrom
josef-pkt:copula_franktau
Feb 10, 2023
Merged

josef-pkt merged 1 commit into
statsmodels:mainfrom
josef-pkt:copula_franktau

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

closes #8657

add taylor series expansion for tau of FrankCopula

@josef-pkt
josef-pkt merged commit 60688e0 into statsmodels:main Feb 10, 2023
@josef-pkt

josef-pkt commented Feb 10, 2023 •

Copy link
Copy Markdown
Member Author

as reminder to get taylor series expansion with wolfram alpha

  • get taylor series expanson of integrant t / (exp(t) - 1)
  • integrate it from 0 to x to get depye
  • subtract one to get debye minus 1
  • plug taylor series expansion into tau formula: 1 + 4 * (debye_value - 1) / theta so we get a power series instead of 0/0s.

I tried sequential power computation but it didn't seem to make a difference

def tau_exp(x):
    x = np.asarray(x)
    tau = x * (1/9 + x**2 * (-1/900 + x**2 *(1/52920 + x**2 *(-1/2721600 + x**2 *(1/131725440 + x**2 *(-691/4249941696000))))))
    return tau

I didn't try more variations to check numerical precision. Also, I didn't check how many expansion points are really useful.

I also tried the series with Bernoulli numbers
https://en.wikipedia.org/wiki/Debye_function#Series_expansion
but only with coefficients computed as floats, not as integer fraction.

numbers copied from wikipedia page

# Bernoulli numbers
bn = np.array([1, 1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0, 5/66, 0, -691/2730, 0, 7/6, 0, - 3617/510])
len(bn)
17

my dev notebook: try_franktau_debye.ipynb

@josef-pkt
josef-pkt deleted the copula_franktau branch February 10, 2023 03:36
@josef-pkt

Copy link
Copy Markdown
Member Author

I didn't add unit tests for negative theta

FrankCopula().tau(-1), FrankCopula().tau(-0.05), FrankCopula().tau(-1e-4), FrankCopula().tau(-1e-5)
(-0.11001853644550241,
 -0.00555541667257152,
 -1.1111111110000001e-05,
 -1.1111111111100002e-06)
> tau(frankCopula(param = -1, dim = 2))
[1] -0.110018536448993
> tau(frankCopula(param = -0.05, dim = 2))
[1] -0.005555416672567759
> tau(frankCopula(param = -1e-4, dim = 2))
[1] -1.111110969986839e-05
> tau(frankCopula(param = -1e-5, dim = 2))
[1] -1.111073345105851e-06

negative correlation in archimedean copulas is untested and likely not fully supported. I guess not supported in rvs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG/ENH: Kendall’s tau of FrankCopula wrong for small theta

1 participant