Question on Using Stan for Bayesian Perception Models with Numerical Integration

Dear Stan and Bayesian modeling experts,

I have a question regarding models that require numerical integration. In cognitive neuroscience, Bayesian perception models are commonly used to understand perceptual and decision-making processes. These models posit that people have a noisy observation distribution p(x \mid s) in the brain and make inferences about the true stimulus s based on this noisy observation, resulting in a posterior p(s \mid x). Here, s is the true stimulus, and x is the internal (and noisy) observation.

And experimenters/modelers not have access to the participant’s internal observation x, making it a latent variable. To compute the model likelihood, we typically need to marginalize over x. In some cases, this can be done analytically, but in many others, numerical integration is required.

In my (humble) understanding, likelihood functions involving numerical integration are often non-smooth and potentially unstable. In the literature, when maximum likelihood estimation is used in such settings, researchers often rely on Bayesian optimization methods such as BADS, which do not require gradients and are better suited for optimizing non-smooth likelihoods.

Given that Stan performs gradient-based inference (e.g., using Hamiltonian Monte Carlo with leapfrog integration), and that its numerical integration functions also require gradients, I wonder: Is Stan suitable for Bayesian perception models that require numerical marginalization over latent variables via numerical integration?

Thank you very much for your time and insights!

Best regards,

1 Like

That is heavily dependent on the actual model formulation. ODE models, for instance, are quite common and involve integrating differential equations.

MLE is often not suitable not because of gradients, but because they rely on optimization algorithms that are unable to deal with the complexities of the likelihood surface, whereas basic MCMC methods can outperform it. HMC, as used in Stan, won’t normally suffer from the same issues of MLE, for a number of reasons.

Generally speaking, the suitability of Bayesian and MCMC methods in general, and HMC in particular depends on the specific problem at hand, but they are normally the most powerful methods out there for large and/or complex models.