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
SMC change initialization #2755
Conversation
hmm, I am not sure this will actually work, as using metropolis is not the same as direct sampling from the prior |
Hi @junpenglao I also had may concerns at first but then I realize that to get proper samples using SMC, you only need to start from any easy to sample distribution that covers the entire solution space and then slowly move from this distribution to the posterior distribution. Starting from the prior is just one convenient choice. In other domains (like statistical mechanics) where priors are not explicit, methods similar to SMC start from a high temperature that is equivalent to start from a flatter distribution and then slowly cool down the system. The computation of the samples seems to be more or less insensitive to the details of the starting distribution, I use for example over-dispersed points. Contrary to this the computation of the |
Thanks for the explanation! |
And we are back to initialize directly from the prior!!! I also changed the way SMC auto-tune Metropolis proposal distribution. I basically follow the recommendations in Transitional Markov Chain Monte Carlo Method for Bayesian Model Updating, Model Class Selection, and Model Averaging. Briefly, they recommend to multiply the weighted covariance matrix ( |
Hey guys! Thanks a lot for this explanation @aloctavodia ! I was totally unaware of these things as I am no statistician. I prefered to have the tuning adaptively based on the acceptance rate as it was already in the metropolis. Removing the adaptive scaling maybe better for some models but I found it was much better performing for my type of problems. Having the algorithm adaptively how it was, is from the Minson 2013 paper mentioned in the doc string. As I mentioned this implementation is not exactly the same as in the TMCMC paper. Just parts of it. So I would vote agains removing the adaptive scaling. If you dont want any adaptation simply set tune=False and set scaling=0.4 when you initialise the sampler .... But again if this interferes with calculating the evidence then we should discuss it further of course. SO for my problems the adaptive stepping is really important. Ah cool I just saw that you worked on getting it working for transformed variables as well! Awesome! Good job! |
@hvasbath Thanks for the feedback I will go back with the tunning changes. It is very interesting that your models works better with the metropolis auto-tunning and worst with the weighed covariance scaling, probably this, together with the results I am getting for the marginal likelihood are indications that there is room for improvement in the computations of the weights, I will work on this. Could you send me (maybe by e-mail) one of your models, I would like to have some real-world models beside my own to test SMC. |
All my real world models are in my "beat" repository. In src/models.py, but I fear the coding there maybe a little unusual for you. Also you would need some data which I would have to send you. As it is a real world application you have quite some other dependencies. In the website there is a description how to install beat and its dependencies. If you want to try it. I fear I have no simpler example- sorry for that! |
Thanks @hvasbath. I will take a look at beat. |
If I am not mistaken @junpenglao also had some real world applications which seemed much simpler to be implemented. Maybe you could do testing on one of his models as well in case getting beat to run takes too much time. |
I have codes to compare mixed effect model (with simulation and real data) in https://github.com/junpenglao/GLMM-in-Python |
* initialize smc using sample() insted of random numbers * use metropolis * init from random and modify scaling * fix indentation * update trace reference values * revert tuning changes * revert tuning changes * update release notes
Unfortunately #2749 is not a general solution of #2742. The problem arise when asking for random samples for distributions that have other distributions as parents, for example the
z
variable in @junpenglao example (#2742 (comment)). I am under the impression this problem have arisen before.This PR takes a different approach, instead of getting samples from the prior by using random methods of each distribution, it just sample from the prior using
metropolis
. It seems to work OK, so far but I will like to run more tests to ensure this is a good approach.