florianhartig / BayesianTools

General-Purpose MCMC and SMC Samplers and Tools for Bayesian Statistics
https://cran.r-project.org/web/packages/BayesianTools/index.html
117 stars 29 forks source link

Marginal parameter uncertainty plot #218

Closed Catarinaxa closed 3 years ago

Catarinaxa commented 3 years ago

Hi ,

I used the bayesianTools package in order to calibrate my model that hold almost 90 parameters. The calibration converged as it was checked by gelman-rubin test , also by measuring error metrics e.g. RMSE.

Now, I want to plot marginal parameter uncertainty using a violin plot type. Is there a specific function in the R/BayesianTools that allow such operation.

NB: whenever I try the following function R stop working.

marginalPlot(mcmc_out, type = 'v' , getSample = 5000 )

With regards

florianhartig commented 3 years ago

Hi, you have the right function already. What happens if you just type marginalPlot(mcmc_out)?

florianhartig commented 3 years ago

p.s.: if you don't like our function, you can convert BayesianTools output to a coda object via getSample(mcmc_out, coda = T) and use one of the many packages that plot coda mcmc objects.

But normally, marginalPlot should work, and it would be best to use it because it will also be able to access your prior and show prior vs posterior and all that.

Catarinaxa commented 3 years ago

Hi, you have the right function already. What happens if you just type marginalPlot(mcmc_out)?

After doing that I got 5 parameters densities over 20 ( result in the image joint )

Rplot

Catarinaxa commented 3 years ago

p.s.: if you don't like our function, you can convert BayesianTools output to a coda object via getSample(mcmc_out, coda = T) and use one of the many packages that plot coda mcmc objects.

But normally, marginalPlot should work, and it would be best to use it because it will also be able to access your prior and show prior vs posterior and all that.

Thank you for the proposition I will try coda package in case BT doesnt work. In fact what I am expecting from the above function ( marginal violin plot ) is a plot such this in the image joint .

With regards

image

florianhartig commented 3 years ago

Hi Catarinaxa - OK, when I understand correctly, you have 20 parameters, but the plots only display the first 5?

Usually, the plots should work, I think there must be some issue in your chains. It's hard to diagnose this from a distance. If you want, you can post a link to your fitted model here (e.g. a dropbox link, just save the mcmc_out with save() ), then I can have a look what the problem is.

Catarinaxa commented 3 years ago

Hi Catarinaxa - OK, when I understand correctly, you have 20 parameters, but the plots only display the first 5?

Usually, the plots should work, I think there must be some issue in your chains. It's hard to diagnose this from a distance. If you want, you can post a link to your fitted model here (e.g. a dropbox link, just save the mcmc_out with save() ), then I can have a look what the problem is.

Hi Florian. Indeed only 5 parameters were reported .

You will find attached (dropbox file) the mcmc data.

Many thanks.

https://www.dropbox.com/s/w3c9rtp1cq501r1/mcmc_out.rda?dl=0

Catarinaxa commented 3 years ago

Hi Florian,

I converted mcmc_out result to a dataframe , then I exported it to python , with the wonderful seaborn package, I was able to carry out violinplot.

Many Thanks

télécharger