-
Notifications
You must be signed in to change notification settings - Fork 12
first shot for add vcov #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This looks great, although I think it would be better (more generic) if everything happened in the outer level, without having to go inside the different methods, so that we get vcov whatever the fitting method. I will take a look tomorrow to see what I can do. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #311 +/- ##
==========================================
+ Coverage 74.50% 78.55% +4.04%
==========================================
Files 84 85 +1
Lines 4837 4994 +157
==========================================
+ Hits 3604 3923 +319
+ Misses 1233 1071 -162 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I understand, but sometimes one technique is used for MLE and another for moment methods, finally the safe fallback to light Jackknife because I think a bootstrap would be too heavy |
|
So if one technique is for MLE and the other one for moment methods, then we could simply dipatch on the method, or even add a new argument
Let me look at your code and try to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Santymax So I think i have it working now :
julia> U = rand(GaussianCopula([1.0 0.3 0.2; 0.3 1.0 0.4; 0.2 0.4 1.0]), 300);
julia> fit(CopulaModel, GaussianCopula, U)
────────────────────────────────────────────────────────────────────────────────
[ CopulaModel: Gaussian d=3 ]
────────────────────────────────────────────────────────────────────────────────
Method: mle
Number of observations: 300
────────────────────────────────────────────────────────────────────────────────
[ Fit metrics ]
────────────────────────────────────────────────────────────────────────────────
Null Loglikelihood: 0.0000
Loglikelihood: 50.4789
LR (vs indep.): 100.96 ~ χ²(3) ⇒ p = <1e-16
AIC: -94.958
BIC: -83.847
Converged: true
Iterations: 0
Elapsed: 0.000s
────────────────────────────────────────────────────────────────────────────────
[ Parameters ]
────────────────────────────────────────────────────────────────────────────────
Parameter Estimate Std.Err z-value p-val 95% Lo 95% Hi
Σ₁₂ 0.2793 0.0538 5.196 2.038e-07 0.1740 0.3847
Σ₁₃ 0.2057 0.0569 3.615 0.0003009 0.0942 0.3173
Σ₂₃ 0.4754 0.0435 10.924 <1e-16 0.3901 0.5607
julia>ulia> U = rand(ClaytonCopula(3, 3.5), 300);
julia> fit(CopulaModel, ClaytonCopula, U; method=:itau)
────────────────────────────────────────────────────────────────────────────────
[ CopulaModel: Archimedean d=3 ]
────────────────────────────────────────────────────────────────────────────────
Method: itau
Number of observations: 300
────────────────────────────────────────────────────────────────────────────────
[ Fit metrics ]
────────────────────────────────────────────────────────────────────────────────
Null Loglikelihood: 0.0000
Loglikelihood: 456.7272
LR (vs indep.): 913.45 ~ χ²(1) ⇒ p = <1e-16
AIC: -911.454
BIC: -907.751
Converged: true
Iterations: 0
Elapsed: 1.165s
────────────────────────────────────────────────────────────────────────────────
[ Parameters ]
────────────────────────────────────────────────────────────────────────────────
Parameter Estimate Std.Err z-value p-val 95% Lo 95% Hi
θ 3.5488 0.0000 3548815.824 <1e-16 3.5488 3.5488
julia>julia> U = rand(BB1Copula(2, 1.5, 3.2), 300);
julia> fit(CopulaModel, BB1Copula, U)
────────────────────────────────────────────────────────────────────────────────
[ CopulaModel: Archimedean d=2 ]
────────────────────────────────────────────────────────────────────────────────
Method: mle
Number of observations: 300
────────────────────────────────────────────────────────────────────────────────
[ Fit metrics ]
────────────────────────────────────────────────────────────────────────────────
Null Loglikelihood: 0.0000
Loglikelihood: 376.9690
LR (vs indep.): 753.94 ~ χ²(2) ⇒ p = <1e-16
AIC: -749.938
BIC: -742.530
Converged: true
Iterations: 8
Elapsed: 2.469s
────────────────────────────────────────────────────────────────────────────────
[ Parameters ]
────────────────────────────────────────────────────────────────────────────────
Parameter Estimate Std.Err z-value p-val 95% Lo 95% Hi
θ 1.5194 0.2542 5.978 2.259e-09 1.0213 2.0176
δ 2.9502 0.2617 11.275 <1e-16 2.4373 3.4630
julia>julia> x = rand(SklarDist(ClaytonCopula(3, 1.7),(Gamma(2,3), Pareto(), LogNormal(0,1))),1000);
julia> fit(CopulaModel, SklarDist{ClaytonCopula,Tuple{Gamma,Pareto,LogNormal}}, x)
────────────────────────────────────────────────────────────────────────────────
[ CopulaModel: SklarDist (Copula=Archimedean d=3, Margins=(Gamma, Pareto, LogNormal)) ]
────────────────────────────────────────────────────────────────────────────────
Copula: Archimedean d=3
Margins: (Gamma, Pareto, LogNormal)
Methods: copula=mle, sklar=ifm
Number of observations: 1000
────────────────────────────────────────────────────────────────────────────────
[ Fit metrics ]
────────────────────────────────────────────────────────────────────────────────
Null Loglikelihood: -6062.1153
Loglikelihood: -Inf
LR (vs indep.): -Inf ~ χ²(1) ⇒ p = 1
AIC: Inf
BIC: Inf
Converged: true
Iterations: 1
Elapsed: 3.258s
────────────────────────────────────────────────────────────────────────────────
[ Dependence metrics ]
────────────────────────────────────────────────────────────────────────────────
Kendall τ: 0.4290
Spearman ρ: 0.5995
Blomqvist β: 0.1464
────────────────────────────────────────────────────────────────────────────────
[ Copula parameters ] (vcov=hessian)
────────────────────────────────────────────────────────────────────────────────
Parameter Estimate Std.Err z-value p-val 95% Lo 95% Hi
θ 1.5026 0.0515 29.184 <1e-16 1.4017 1.6035
────────────────────────────────────────────────────────────────────────────────
[ Marginals ]
────────────────────────────────────────────────────────────────────────────────
Margin Dist Param Estimate Std.Err 95% CI
#1 Gamma α 2.1972 0.0918 [2.0173, 2.3770]
θ 2.7371 0.1284 [2.4855, 2.9887]
#2 Pareto α 0.9967 0.5524 [-0.0859, 2.0794]
θ 1.0016 0.5560 [-0.0881, 2.0914]
#3 LogNormal μ -0.0028 0.0313 [-0.0641, 0.0585]
σ 0.9886 0.0221 [0.9452, 1.0319]
julia> Now by default everything is computed, and i have tried to make the output better-looking. Also I have fixed the marginal vcov.
However this require a few tests: there are now many possibilities (fitting method for the copula, for the sklar, vcov method, etc...) and thus we need to test all of them. I will now review once more the code to try to simplify it again, if you could propose :
1° tests that corresponds to these new functionalities
2° Proper documentation of what the show() methods outputs
That would be nice :)
…s.jl into pr/Santymax98/311
|
@Santymax98 Okay this is correctly merged now ! Do not forget to |
|
@Santymax98 : Regarding specific methods for the BBCops generator derivatives, I have simply commented out your code for the moment, since it is not the main question of this PR. Once this one is merged, if you want to test this idea again please in another pull-request. This is already a very messy pull-request no need to add more. Let's see what the tests say |
|
I completely agree. It's not essential, and perhaps we can run some benchmarks to see if it's better or not at the appropriate time. For my part, everything's fine. |
|
Okay. In the mean time, i would like to validate the dependence metrics to be certain that they work on every model we have. I will therefore push a nex tests into the generics and we'll see :) It will probably fail on a lot of cases, but thats good we have to fix them |
|
I think the same and maybe polish the tail estimators and theorical tails... |
|
@Santymax98 Okay I think we are good to merge now. The only missing thing is correct documentation of the fitting interface and the vcov things. I was going to do it, but if you could do it that would be nice. I will rather concentrate myself on 1) producing benchmarks so that we can see where are the problematic points and 2) make the testing framework a bit faster, 45minutes is painfully slow... |
Okay, let's forget about the pr I made by mistake.
In this PR, I added the
vcovfunction for the fit API. This ensures that it's the user's decision whether to calculate it or not. I also added a function to print the values for copula measurements (again, the decision is up to the user). Here are some examples.For Archimedean Copulas
Copulas with more than 2 params... with fallback to avoid errors
For SklarDist
In this last case, I had trouble getting the marginal vcov...