Repository navigation
REF: move copula out of sandbox, and refactor, copula directory - #7296
Conversation
|
Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-03-22 15:37:29 UTC |
|
last commit is WIP, in the middle of refactoring when discussion about location came up. |
|
This pull request introduces 3 alerts and fixes 2 when merging 9270e67 into fb3e061 - view on LGTM.com new alerts:
fixed alerts:
|
9270e67 to
d07e424
Compare
|
This pull request introduces 3 alerts and fixes 2 when merging d07e424 into fb3e061 - view on LGTM.com new alerts:
fixed alerts:
|
|
no related failures on azure, linting complaints are mainly unused variables. this has now unit tests for CopulaDistributions cdf against R, using uniform, and for EVtawn also genextreme next cleanup and then adding missing pieces For archimedean maybe define logpdf and add logderiv, defined as log(deriv), and same for deriv2 to transformation. Based on browsing some of the code, that should work better than log(pdf) |
|
This pull request introduces 2 alerts and fixes 4 when merging 46de0ea into fb3e061 - view on LGTM.com new alerts:
fixed alerts:
|
|
need to decide on splitting module from previous PR
I'm still not sure TBC I don't like two api files: split copulas in 4 public modules, and additional modules if we ever get nested copulas.
and collect everything in other possible modules avoiding circular imports: individual copula modules import special BV classes can be added to individual copula modules, if we really need them. |
|
This pull request introduces 2 alerts and fixes 4 when merging 4619a48 into fb3e061 - view on LGTM.com new alerts:
fixed alerts:
|
|
my guess right now: |
|
namings for ev copulas I want to change names for authors to commonly used names in extreme value theory, AsyLogisticCopula or AsymLogisticCopula instead of We need some alias docs or dict for discoverability, e.g. currently I have |
| def copula_power_mv_archimedean(u, transform, alpha, beta, args=(), axis=-1): | ||
| '''generic multivariate Archimedean copula with additional power transforms | ||
|
|
||
| Nelson p.144, equ. 4.5.2 |
There was a problem hiding this comment.
section for this is 2-parameter archimedean copulas
a few illustrative examples but no details on them, and not "named"
they are transformations of table 4.1 archimedean copulas
|
I found a Diplomarbeit with derivatives of bivariate extreme value copulas, generic formulas in appendix A Also, on page 18 and 19 equ 2.21 - 2.31 has conditional distribution and density for bivariate EV copulas in terms of Pickand's dependence function. conditional copula/distribution density This needs to wait until I have derivatives of Pickand's dependence functions A and I ran into Archimax copulas which combine elements of archimedean generator and Pickand's dependence function. In which module would that one go? |
|
resurrecting another old idea: http://jpktd.blogspot.com/2012/12/visual-inspection-of-random-numbers.html update I found a paper that I downloaded a long time ago (not read, only 5 citations in google scholar) I also saw a recent article, abstract sounds good, but I didn't look at it related aside: scipy.interpolate has a one-dim piecewise bernstein polynomial interpolation and a linear d-dim interpolation class. I have never used either of them. |
|
This pull request introduces 4 alerts and fixes 4 when merging 358c72b into fb3e061 - view on LGTM.com new alerts:
fixed alerts:
|
|
another idea: plot bivariate marginal cdf in multivariate copula IIRC, the marginal subset cdf just has ones at all other positions, so we can get a |
|
another idea: reusing scipy distribution generic cdf->ppf inversion and rvs collection for 6 cond. cdf is in Joe 1997 p. 147 (only Frank and an "unknown" copula have closed form ppf) I guess not. If we want to use our own quasi-random numbers, then we need our own |
|
current limitation Usage, e.g. time varying copula correlation, where copula args are modeled as varying by observation, where we have regression case for copargs and not just marginal args. |
|
If the distribution has beta marginal, why is the contour plot not on [0,1]x[0,1]? |
|
Oh those are integer indices. |
|
I didn't specify the x-axis in the contour plots. I have those in another notebook but copy pasted the plot part from an earlier version. Also it would be nice to have the same level sets across plots, but I have not tried to figure out how to set the location of level sets in contour plot. |
|
I cleaned up the contourplot and updated the notebook in the gist (plus some dev code to check get_marginal) Keeping the same |
|
This pull request introduces 8 alerts and fixes 4 when merging 4bcdd14 into 7d707cf - view on LGTM.com new alerts:
fixed alerts:
|
|
I'm stopping with Bernstein for now. BernsteinDistribution has all parts that I want or need for now. A bit more work on copula code, then I plan to merge this, so @tupui can merge his code into this. |
|
This pull request introduces 8 alerts and fixes 4 when merging 3abd5b9 into 7d707cf - view on LGTM.com new alerts:
fixed alerts:
|
|
derivatives in last commit for pickands dep func are derived in wolfram alpha and edited by hand to get a compact form
remove old, now likely redundant code: leave for later when we have case specific methods in classes, currently much is generic in ev and archimedean copula classes |
|
related to pdf of EV copulas: use derivatives of copula function directly if that is available I haven't looked specifically for this yet. Currently, everything in the EV copulas uses the definition through Pickand's dependence function. |
|
There is likely a bug in the EV copula generic pdf computation from depfunc. update I didn't manage to fix the pdf based on the reference Diplomarbeit cited above #7296 (comment) Instead I used "On Densities of Extreme Value Copulas_ma-doyon.pdf" page 22, 23 equ (36). |
|
I'm not able to match up pdf of tawn2 AsymMixed copula with I'm not sure they didn't change some definition or parameterization when computing pdf, cdf. So far, all my evd copula code is still generic with only dep functions as case specific. |
|
checking pdf computed with numerical derivative i.e. 2nd cross derivative in bivariate case numdiff pdf agrees with pdf from dep func, (at least at equal u point) To roundtrip checking consistency, I will need functions to compute nonparametric estimate of pickand's dep func from rvs and/or a way to compute dep func from copula (cdf or pdf) itself. I will need some documentation to answer: Why do statsmodels and evd not agree in this? Or I still have bugs, in pdf or other parts. |
|
bugfixes and redefinition like flipping asymmetry Now matches evd for AsymLogistic, AsymNegLogistic, AsymMixed and HR, for cdf and genextreme copula distribution pdf HR and AsymNegLogistic (joe) have inverted dependence parameter, The unit test for ev copulas and ev-gev distribution needs to be reorganized, currently a bit messy in the lists for parameterized unit tests. |
|
This pull request introduces 8 alerts and fixes 4 when merging 24f57c7 into 6d4d588 - view on LGTM.com new alerts:
fixed alerts:
|
|
checking briefly book "Statistics of Extremes - Theory and Application" chapter 8 and 9 again evd has the formula in the notes for the same will apply to stable dependence function copula package: The only part that we really want to have is to match index of asymmetry parameters to index of random variable. otherwise it's just a convention of dropping first or dropping last term for values in simplex. Also in articles by Genest and coauthors, e.g. for gof, they use |
|
This pull request introduces 4 alerts and fixes 4 when merging 60be727 into 6d4d588 - view on LGTM.com new alerts:
fixed alerts:
|
|
This pull request introduces 4 alerts and fixes 4 when merging 25d197a into 6d4d588 - view on LGTM.com new alerts:
fixed alerts:
|
|
all green (1 unrelated test failure with pandas in pre-release testing) merging, |
|
@tupui it's merged |
Great thanks! I will update my PR and let you know then. |
same/similar commits as #7292 but moving to distributions.copula directory
(cherry-picked and amended each commit of 7292)