florianhartig / BayesianTools

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

Questions about BT #247

Open florianhartig opened 1 year ago

florianhartig commented 1 year ago

Redirected from https://theoreticalecology.wordpress.com/2017/10/05/the-bayesiantools-r-package-with-general-purpose-mcmc-and-smc-samplers-for-bayesian-statistics/

This looks like a really great package, and I’m eager to try it, but I have a few questions that I can’t seem to answer from the other posts or documentation. Very sorry if I’ve missed any relevant documentation! I’ve already implemented the model in my own homespun mcmc routine, but I wanted to try something more powerful because the efficiency of my routine is very poor (likelihood involves a slow quadruple integral, and mixing is poor).

My first question is:

***If I have an R function “posterior(params)” that returns the posterior probability for an input set of parameters, could the BayesianSetup be created as follows?

setup = createBayesianSetup(posterior)

I think the answer to the question is “yes” but want to confirm! (The examples I’ve seen use a likelihood function or a function with lower and upper bounds and there is no explicit mention that I can see about how to implement a posterior function). Related to the first question:

***Could such a posterior function be input directly into the runMCMC function?

My second question is:

***Does the posterior need to be normalized (i.e., posterior when integrated across parameter values = 1)?

I think the answer to this question is “no”, but I want to confirm… The normalization constant would be very time consuming to estimate. In my mcmc routine (and standard MH MCMC), the normalization constants cancel in the acceptance ratio, so they don’t need explicit calculation, but I wasn’t sure if that was the case for all the sampling techniques your package employs.

My third question is about the prior. Well, I suppose this question is irrelevant if the answers to my first and second questions are “yes” and “no” respectively. My prior is defined on an implicit manifold, and there is no explicit prior for each parameter. This is analogous to the inputs of a Dirichlet needing to be positive and summing to 1. In my case, there are several parameters (coefficients of polynomials) that define the mean and variance of a beta distribution. The prior is not directly for the polynomial coefficients, but rather the prior is set for the mean and variance of the beta distribution (where the prior functional form for the beta mean or variance could be uniform, exponential (for variance), Gaussian, … with shape parameters positive, var < mu(1-mu)). Clearly, this puts constraints on which combinations of coefficients are permissible for a given dataset, thereby yielding an implicit joint distribution as the prior for the coefficients, but there is no specific prior probability / density for any given coefficient.

***Is there a mechanism in place in the BayesianTool package to implement such a prior given by the above description (i.e. an implicit joint prior distribution defined on an implicit manifold).

I've already written a function that takes the data and some other constraints and outputs a "prior" function that accomplishes this, but I was curious if there was a mechanism in place to do this in your package. If not, do you know of any MCMC software packages that can do this?

Sorry for the long post! If the answers to the first questions are "yes" and "no", respectively, there is no need to answer the third question (unless it might be of general interest to your users).

Many thanks!