Skip to content

ENH: Add multivariate pdf (dim>2) for Frank and Gumbel copula - #8649

Open
Tobi0 wants to merge 1 commit into
statsmodels:mainfrom
Tobi0:archimedean_pdf_multivariate
Open

Tobi0 wants to merge 1 commit into
statsmodels:mainfrom
Tobi0:archimedean_pdf_multivariate

Conversation

@Tobi0

@Tobi0 Tobi0 commented Feb 3, 2023

Copy link
Copy Markdown
Contributor

I implemented multivariate copula density for Frank and Gumbel (archimedian) using https://arxiv.org/abs/1207.1708

I did some optimizations for the _special module for sterling numbers.
Regarding the polylogarithm: I hope it is ok, that I added an import from package mpmath because this implementation is much more stable numerically.

Tests were added for higher dimensions. However I am not totally sure if I did this the intended way.

- BUG/REF copula another round for 0.13 (:pr:`7648`)
- Temporarily change the default RNG in check_random_state (:pr:`7652`)
- More copula improvements for 0.13 (:pr:`7723`)
- Add multivariate pdf (dim>2) for Frank and Gumbel copula

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 0.13, this will be in 0.14 o4 0.15

@josef-pkt

Copy link
Copy Markdown
Member

Thanks for the PR

I think we should keep special casing k_dim = 2...4 for pdf that need _special
I guess those are faster and automatically vectorized

I guess pdf that need sterling or polylog will not be automatically vectorized for u u.shape = (nobs, k_dim)

z = np.array(z)[..., None]

k = np.arange(n+1)
k = range(n + 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be an iterator and not a list

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the same problem like in gumbel pdf (see comment) because the elemnts of np.arange are int32 and therefore the cache of sterling2, too, which quickly leads to overflow.

@Tobi0

Tobi0 commented Feb 6, 2023

Copy link
Copy Markdown
Contributor Author

I guess pdf that need sterling or polylog will not be automatically vectorized for u u.shape = (nobs, k_dim)

They are, because it was necessary for the tests. (therefore this ugly extension in the power of pda)
polylog is vectorized with np.vectorize

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copula density not correct for d>2

2 participants