-
Notifications
You must be signed in to change notification settings - Fork 10
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
Σ field from ArchimedeanCopula removed in patch release #186
Comments
So, @Vaibhavdixit02, taking a deeper look, I am not sure if I made a breaking change or if you used internals fields that you should not: The The constructor of the Gaussian copula might have evolved to specialize this way, indeed, but I am not sure this is breaking (IDK really) I think you need a way to subset the dimensions of a |
Ok After PR #187 gets merged and released, a new function and replace this line : by sample_complement = rand(Copulas.subsetdims(input_distribution,idx_minus), n_outer) |
Released in version 0.1.22. Please tell me if this resolves your issue or not, I can take another look if you want. |
Thank you for such a detailed follow-up @lrnv, really appreciate it.
Ah, since it was a field of a public struct I didn't expect it to be only internal. Your point about this only existing for EllipticalCopulas is accurate, I am actually not sure anymore where the ArchimideanCopula shows up since none of the tests use it and only GaussianCopula, I will have to investigate this better there's probably a default somewhere that's the reason for it.
Thanks a lot, this greatly simplifies things! |
In the tests the identity matrix was being used for the covariance matrix of the Gaussian Copula and that hit https://github.com/lrnv/Copulas.jl/blob/main/src/EllipticalCopulas/GaussianCopula.jl#L40 thus leading to an error with |
That branch probably wants to check for all diagonal matrices? |
So yes this is where the bug came from : I (silently) changed the output type for diagonal matrices. In fact since we are dealing with correlation matrices and not covariance matrices, diagonal <=> identity... But now I see that the I continue to think this is not breaking, but maybe I'm wrong. I agree that the behavior can be surprising, but it's actually what Distributions.jl is doing when returning an Exponential RV for some specific inputs of the Gamma (IIRC). Is your problem fixed now with the new release ? |
Aaaand maybe I should state a bit more clearly what is API and what is internals in the docs, I never took the time to do that :) |
So if you do #190 I don't understand how I can handle the code path to not check for the sigma field? |
Is that what you need ? Otherwise please explain a bit more I am not getting your issue. |
Hahaha this one is much more complicated to do generically for any dependence structure. Basically for GaussianCopula, you can keep what you have (but then restrict the method to appropriate sklardist), and otherwise for other copulas you need #150 to be done. So for independent copula, conditional sampling is simple subset sampling. Do a Union splitting. For the moment I think you should only accept gaussian and independent copulas, as this behavior is not implemented for others. |
But why do I lose the covariance matrix I have used to create the distribution - even if the behavior is more correct now, I think the matrix should remain available somewhere? |
OR, and this is better, wait until Monday and I'll think about the right interface for #150. Then you can keep the généricité and have nice method failure for other copulas directly coming from here... |
A MWE for my usecase haha Yeah sure I don't mind waiting. Thanks for the help! |
@Vaibhavdixit02 I was not able to push directly to your branch here SciML/GlobalSensitivity.jl#134 so the solutino is below. I have tried to do something for #150 but it is a large project and I do not have the time right now. So the solution for the moment is as follow:
Basically you'll just have to change the current signature function cond_sampling(distribution::SklarDist,
n_sample::Int,
idx::Vector{Int},
idx_c::Vector{Int},
x_cond::AbstractArray) to function cond_sampling(distribution::SklarDist{GaussianCopula{d,TΣ},Tm},
n_sample::Int,
idx::Vector{Int},
idx_c::Vector{Int},
x_cond::AbstractArray) where {d,TΣ,Tm} and add another method : function cond_sampling(distribution::SklarDist{Independentcopula{d},Tm},
n_sample::Int,
idx::Vector{Int},
idx_c::Vector{Int},
x_cond::AbstractArray) where {d,Tm}
# conditional sampling in independent random vector is just subset sampling.
rand(subsetdims(distribution, idx, n_sample) # you might need to transpose this ?
end and that would be enough. When #150 has a proper interface, i'll ping you with a PR to enlarge the applicability of Shapley methods to any I would keep the |
You can fork the repo and create a PR to my branch? |
Done here SciML/GlobalSensitivity.jl#157 |
https://github.com/SciML/GlobalSensitivity.jl/actions/runs/8392054624/job/22983804323?pr=134#step:6:434 I am confused how to debug this, since there isn't clear how the code can be adapted for this here https://github.com/SciML/GlobalSensitivity.jl/blob/master/src/shapley_sensitivity.jl#L111
The text was updated successfully, but these errors were encountered: