How can uncertainties in a generative model be propagated to an overall log-likelihood?

I am trying to use a Bayesian approach to carry out model selection and estimate the posterior distributions for parameters in a peak fitting scenario (quasi elastic neutron scattering). The generative model can be described by the following:

y_{m, calc}(x_m, \Theta) = R(x_m) \circledast \left[f_0(x_m, \theta_0)+f_1(x_m, \theta_1)+...+f_n(x_m, \theta_n)\right]

i.e. a sum of n functions that are then convolved with the instrument response function, R. Each of the n functions has a set of parameters, \theta_n, which go towards making the overall parameter vector, \Theta.
If R is analytical then it’s straightforward to calculate the log-likelihood of the measured data.

\ln p(y|x, \Theta) = -0.5 * \sum_m [(\frac{y_{m, calc}(x_m, \Theta) - y_{m, obs}}{\sigma_m})^2 + \ln(2\pi \sigma_m^2)]

where \sigma_m are the uncertainties of the m measured points, y_{m, obs}.

So far this is a ‘normal’ non-linear least squares problem (f_n are non-linear).

However, I don’t know how to amend the log-likelihood if the response function, R, is no longer analytical but also has experimental uncertainties because it’s measured.

Can anyone provide guidance on this topic? Or is it better suited to e.g. stackoverflow?

In PyMC, you specify a generative graph. This is different to say Stan, where you specify the log probability computation. As long as your R function is made of “measurable” operations, PyMC will automatically work out what the correct logp adjustments should be. This includes if you want to associate R(x_m) with observed data, then use its conditional output in the computation of y_{m, calc}

Dear Andyfaff,

I’ve been working on something very similar to your question recently.
My model can be described as a sum of n functions, too, but I’m having trouble defining the parameters prior, and SMC sampling always fails to converge, even though I used a large number of samples. How did you define the prior in your problem?

I have no solution yet.