Parallel evaluation of likelihood function gives wrong results
The function tempered_likelihood
called by hssmc reads
logpostkernel = -postkernelfun(xparam);
logprior = Prior.density(xparam);
loglikelihood = logpostkernel-logprior;
tlogpostkernel = lambda*loglikelihood + logprior;
This implies that logpostkernel
contains the prior density. However, the prior density is not evaluated because the persistent variables in priordens
are not copyied over to the parallel pool (see here):
persistent id1 id2 id3 id4 id5 id6 id8
persistent tt1 tt2 tt3 tt4 tt5 tt6 tt8
A call from dsge_likelihood
to priordens
inside any parallel loop then returns 0.
The workaround for tempered_likelihood
is trivial (just rename logpostkernel
and remove the third line), but since persistent variables are also used on other occasions, this might warrant further investigation.