I am new to MCMC and theano, and now I have three equations similar to the following equations:
r1 = ……
r2 = ……
r3 = ……
R_a = r1 + r2
R_b = r1 - r3
R_c = - r2 - r3;
Due to the fact that experimental data of R_a, R_b and R_c is available, so I want to use Likehood of R_a, R_b and R_c to do sampling as follow:
But it seems that only one likehood can be used.
I tried to use np.vstack to combine the array, but I encountered the problem of “ValueError: setting an array element with a sequence.”
So how can I do MCMC sampling with Multiple likelihood functions?
The model code is valid and multiple likelihood will be accounted for - I dont see np.vstack in your code, where and how do you use it? The error seems to raise from there.
This is the original model with three likelihoods (where ‘p’, ‘keq’, ‘R’, ‘T_Bottom’ and ‘r’ are the experimental data), and the equations in the red block is the model I want to simulated, but my professor said that the MCMC model should have only one likelihood.
As a result of which, I try to use np.hstack to combine three ‘r’ into one array as follow:
So I want to ask for help that how to construct a likelihood function with a vector or matrix to complete the MCMC sampling. Also I would like to find some reference material or literature on this to simulate different multiple likelihood models with MCMC methods. Thanks!
You don’t need to do anything to your code to get the combined likelihood - behind the scenes, PyMC3 is adding together the contributions from the log likelihoods from each of the 3 lines. Creating a single vector variable is admittedly cleaner and easier to follow, but it won’t fundamentally change the results you get.
As for the ValueError you’re getting, the shapes of the variables you’ve provided in rrr_likelihood aren’t compatible. Can you print off the shapes of these using x.shape or x.tag.test_value.shape?