-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add DIC #271
base: master
Are you sure you want to change the base?
Add DIC #271
Conversation
It looks like this failed due to a compatibility issue. MCMCChains tests on Julia 1.0.5, but StanDump requires Julia 1.1 or higher. What is the best path forward? |
IMO it is a bit problematic that the method requires a parameter Maybe it would be better to remove |
Part of the rationale for creating Thanks for pointing out the issue with |
I totally agree that it would be good to make the statistical methods more modular - this was also the main motivation for changing (most) implementations in MCMCChains to operate on arrays instead of
Using a different name does not resolve the general issue here. MCMCChains does not enforce any specific parameter name for log-likelihood values (if they exist at all) and lets you rename all parameters arbitrarily. So anything that is based on the evaluation of a specific parameter name is likely to be broken - it will error if it does not exist and, even worse, it will yield completely incorrect results if a parameter of this name exists but does not denote log-likelihood values. |
Ok. I understand the issue now. I was suffering from a bit of myopia. I usually use MCMCChains with specific samplers in Turing. So the posterior log likelihoods have a specific name. In that case, the simplest solution is probably adding an additional argument for the variable name:
Do you think something like that would work? |
Yep, I think that sounds good. I would just suggest function dic(chain::Chains, loglik::Symbol)
lps = Array(chain[:, loglik, :])
return dic(lps)
end instead. |
Thanks. I like that better. I modified your method so that |
Do you know why StanDump requires Julia 1.1? |
I'm not sure. Let me find out. |
As noted in tpapp/StanDump.jl#7, I don't quite remember, but if you really need 1.0, PRs are welcome. That said, do you really need 1.0? |
I personally don't need 1.0 (or anything apart from the latest version) but I think it would be unfortunate to drop Julia 1.0 if it can be supported without much effort. Currently, it does not lead to any additional maintenance burden. AFAIK Julia 1.6 might become the new LTS version only after Julia 1.7 is released, so I'm not sure how long it will take until a new LTS version is available. |
Let's see — again, PRs are welcome. Generally I think that so much happened since 1.0 in terms of new features that it does not make sense to support it. |
The current version of StatsModelComparisons.jl uses StanSample.jl for testing purposes. Wouldn't that be an ongoing source of issues if StatsModelComparisons.jl is made part of testing MCMCChains.jl. In the past there was a link between Turing and CmdStan for comparisons. I'm no longer sure that's still the case, but if so, that could also be problematic as it would mix and match CmdStan and StanSample. If there are good reasons to go this route I would suggest to redo the StatsModelComparisons.jl tests using Turing.jl or DynamicHMC.jl. In the PR, in src/MCMCChains.jl line 27: |
"In the PR, in src/MCMCChains.jl line 27: import ModelComparisons: dic uses the initial proposed package name." Good catch. I fixed the import statement. "The current version of StatsModelComparisons.jl uses StanSample.jl for testing purposes." Would this issue be resolved if you specified StanSample in extras instead of compat? It was not clear to me based on the documentation for Pkg.jl. |
I.e., it is used only in the tests? Then it should not be listed among the dependencies but in an |
@devmotion, I noticed that too. Would the conflict be resolved if listed under extras? |
Yes, since the packages listed under |
Just to make sure I understand this right. For the import statement in MCMCChains.jl, StatsModelsComparisons.jl needs to be in the dependencies of MCMCChains right? In StatsModelsComparisons.jl I can turn all examples into Interesting! |
I opened a PR that also uses RecipeBase instead of StatsPlots: StatisticalRethinkingJulia/StatsModelComparisons.jl#4 |
Rob, I believe that is the case. |
Very nice changes David! Thanks a lot. I'll remove the mc_path. At some point I ran in troubles with making it a constant but that was a few years ago. For this package it is not needed. Alvaro definitely used the R and Python sources to do the translations after permission by the author (Aki Vehtari I think used Matlab). I will indeed update the LICENSE.md file. |
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.
I added some suggestions.
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
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.
Looks good to me 👍 I am not sure what's the best way to test the implementation but maybe we could at least call it with some random data to make sure it is not completely broken?
Yeah. That is a good idea. I also added a test to ensure that it fails as expected too. |
I noticed that in the mean time the license of StatsModelComparisons was changed to GPL-3 - does this mean we would have to relicense |
Based on our previous conversation, I was under the impression that the GPL license would only apply to the code for psisloo methods. @goedman, did your plans change? |
Yes, this recent change to only auto-merge packages with OSI-approved licenses was a surprise to me as well. A problem is that TuringLang is a product while StatisticalRethinkingJulia is just for learning purposes. I have derived the WAIC part from the SR implementation so legally it is probably also GPL-ish. But I'm definitely open to change the license file if that is possible and would work for TuringLang. |
@cpfiffer What's your opinion about the license issue? |
Dunno, I'm kind of the wrong person to ask -- I don't know much about licensing issues. |
Unfortunately, I also don't know much about these problems. I would like to fix I also just noticed that StatsBase already defines |
@devmotion, I like your idea of submitting a PR to StatsBase for DIC. I did not know that they implemented other model comparison metrics. I will look at the algorithm for PSISLOO to see if it would be feasible to implement. It looks much more involved, so it is probably a long shot for me. |
Hi all,
I worked with Rob to create a library of model comparison metrics at StatsModelComparisons. This package has a generic interface for using model comparison metrics. This PR provides a method for computing DIC from a chain object. Please let me know if there are any edits you would like me to make.