Repository navigation
Copula 7254 rebased - #7408
Copula 7254 rebased#7408
Conversation
|
unit test only fail with missing matplotlib |
|
coverage report codecov looks screwed up. update the parameterized tests fail locally if I change numbers in the results lists. So codecov coverage changes tab doesn't make sense new tests are also run locally, but lines don't show test coverage, e.g. using -v |
3cce758 to
0b1ed35
Compare
|
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-07-24 01:08:11 UTC |
|
error 1E AttributeError: module 'scipy.stats' has no attribute 'multivariate_t'1 statsmodels/distributions/copula/tests/test_copula.py:344: in TestStudentCopula
|
| if cov is None: | ||
| cov = [[1., 0.], [0., 1.]] | ||
| self.density = stats.t(df=df) | ||
| self.mv_density = stats.multivariate_t(shape=cov, df=df) |
There was a problem hiding this comment.
misleading names:
those are distribution instances and not densities/pdf
43b6bd4 to
a4e399c
Compare
|
something weird why is pytest running the trying again, this time commented out the test class |
|
Ok that was it. pytest didn't run the full test suite. It skipped more than just the (non-test) class that had an error, i.e. stopped collecting. pytest :( |
|
Just seeing this, shall I close #7254 then? What's the plan here @josef-pkt? Let me know if I can still be of help, even just for reviewing it's fine. |
|
We need a copy of multivariate_t for compatibility with scipy < 1.6 I also left currently the multivariate_normal in the compat module. I don't think we need it, but I have not checked that. azure is all green except for style check, mainly line breaks in copied scipy code, needs a pep8 E501 ignore edit |
ea8a6fb to
094bc47
Compare
|
aside: this |
094bc47 to
84f01f0
Compare
|
now all green including style check trying out: plot requires dimension d=2 ValueError Traceback (most recent call last) m:\josef_new\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\distributions\copula\copulas.py in plot_pdf(self, ticks_nbr, ax) ValueError: Can only plot 2-dimensional Copula. also ZeroDivision Warning in plot for GaussianCopula |
|
StudentCopula has default df=1 I got a bit surprised because the contourplot for T copula with gaussian margins looks almost like an X (tilted cross) with df=3 or 4, the contour/scatter plot looks more like a trapezoidal ellipsoid |
|
naming/terminology elliptical distribution cov/corr/scatter/shape matrix What do we call it? correction: AFAICS, standard mv-t shape matrix is the same as the correlation matrix. Variance and cov depend on df and scale, and standard t, mv-t (scale=1) does not have unit variance, but df term should cancel when we compute pearson correlation. -> use |
|
This pull request introduces 4 alerts when merging 33a990f into 4956b3b - view on LGTM.com new alerts:
|
|
unit tests: unnecessary repeated sampling Gumbel margins test just failed locally random draws from copula do not satisfy uniform marginal frequencies, even if the distribution is uniform I'm currently writing a unit test for |
|
This pull request introduces 4 alerts when merging a816c0e into d2a4e6f - view on LGTM.com new alerts:
|
|
two unrelated errors in azuere testing this PR is still green, including style check |
| # this means marginals are independents | ||
| sample = rng.random((n, self.d)) | ||
| else: | ||
| sample = self.copula.random(n, random_state=random_state) |
There was a problem hiding this comment.
why does this not use rng?
what is return of check_random_state
There was a problem hiding this comment.
It's a typo and should read sample = self.copula.random(n, random_state=rng). check_random_state returns an instance of RandomState or Generator (only if a generator was passed).
|
our current univariate ECDF uses
a=b=0 is "weibull" 1 ... n / (n + 1) |
|
maybe I shouldn't ignore ties for ecdf, rankdata I started unit test against R copBasic with this, but arbitrary tie breaking looks fragile and might agree only as long as same sorting algorithm is used across packages. (For Hosmer-Lemeshow grouping I also had tie breaking differences by sort algorithm or tie breaking rules.) I think brute force ecdf on non-ranked data is unique. Other cases might not produce correct ecdf with ties. |
|
design: make dimension a We need copula parameters as method arguments at least for some methods like logpdf/loglike. But we can treat the dimension of the model as fixed. In some cases I kept it currently implicit, e.g. determining dimension from values of random variable u. One reason to do that is that we might precompute some intermediate results for fixed dimension. e.g. Hofert et al have explicit formulas for multi-dimensional pdf/logpdf of 5 archimedean copula families. Gumbel and Joe have a finite sum term that is indepenend of Frank and AMH are messier because they have infinite sum, polylogarithm that doesn't exist in scipy.special. That sum also depends on Hofert, Marius, Martin Mächler, and Alexander J. McNeil. 2012. “Likelihood Inference for Archimedean Copulas in High Dimensions under Known Margins.” Journal of Multivariate Analysis, Special Issue on Copula Modeling and Dependence, 110 (September): 133–50. https://doi.org/10.1016/j.jmva.2012.02.019. |
83f71a1 to
9835ee6
Compare
|
rebased on current main |
|
This pull request introduces 6 alerts when merging 9835ee6 into d2f6634 - view on LGTM.com new alerts:
|
|
it looks like the last commit was unfinished refactoring adding random_state. has syntax error amended and force pushed |
9835ee6 to
1cc0da2
Compare
| """ | ||
|
|
||
| def __init__(self, d): | ||
| self.d = d |
There was a problem hiding this comment.
no one letter names
k_dim or k_vars
| rng = check_random_state(random_state) | ||
| if self.copula is None: | ||
| # this means marginals are independents | ||
| sample = rng.random((nobs, self.d)) |
There was a problem hiding this comment.
this should go through independence copula, not here in base class
|
This pull request introduces 4 alerts when merging 1cc0da2 into d2f6634 - view on LGTM.com new alerts:
|
|
insuffient unit test coverage in several modules https://codecov.io/gh/statsmodels/statsmodels/tree/copula_7254_rebased/statsmodels/distributions/copula
|
|
based on my latest notebook (before the break) I was working on ecdf and beta kernel. AFAICS, I didn't manage to replicate this with package en2 is elnino with april and august in the two columns |
|
@tupui I will merge this today. You could add missing pieces if you have time. One part that needs to be cleaned up and added to is the kendall extreme value copulas will not have a tau or inverse tau directly, because those all have more than one parameter. currently only Frank has conditional distribution of the second rv given the first rv: We might be able to support main parts pdf, cdf for more than two dimension in some Archimedean copulas, maybe gumbel or clayton ? |
|
I forgot to push my latest changes using amend ArchimedeanCopula.cdf and other methods have two docstrings. I fixed it but didn't push it before merging. |
|
Thanks for merging @josef-pkt I will see if I have some time for tau. |
|
Some overview description can go into the module docs. I think GLM has the most of that. examples for usage go into notebooks. I have several notebooks that I started out as usage examples, but then become development notebooks when I needed to try out new features. |
|
@josef-pkt Something else, would it be ok if I added support for QMC? There would not be much to do. We are using Either way the current |
|
Yes to both Qmc would be good to add, but many copula rvs are based on mixtures, and those will not have proper properties. |
amending last commit and getting unit tests to pass