Different lp__ after parallelization with map_rect

Hi everyone,

I have a model that I want to parallelize with map_rect. When I compare the output, the parameter estimates of the parallel and non-parallel versions are pretty similar (maybe not similar enough?), but the lp__ is different. I wonder how this happens. The map_rect version has a vector of “additional” parameters called ‘global_params’. I create it in the transformed parameters block like this:

vector[9] global_params;
  global_params[1] = pdd1;
  global_params[2] = pdd2;
  global_params[3] = tmin_v;
  global_params[4] = tmin_r;
  global_params[5] = dtopt_v;
  global_params[6] = dtopt_r;
  global_params[7] = emt;
  global_params[8] = sigma;
  global_params[9] = smoothness;

so they don’t have extra priors. The global_params is what I give to the map_rect function.
Is there an obvious reason why lp__ should be different between the two versions?


Thanks a lot for any explanation or comments!
Cheers,
Friedrich

Ah, I think I was missing one important point. In the non-parallel version, I use ~ statements, and in the map_rect version, I use target += … There is a difference in how constant terms are treated. I rewrote the non-parallel version so that it also uses target +=. Maybe that fixes it. The model will run for a while. I will give an update tomorrow.

Thanks to anyone who has already spent some time thinking about this, and apologies, I didn’t share the code. I was trying to keep the question as short and general as possible.

Cheers,
Friedrich

1 Like

Ok, the model finished, and lp__ now looks a lot more like it does for the map_rect version. So I guess everything is alright :)

2 Likes

If you want to have target += be equivalent to ~, you can use the unnormalized suffixes in the distribution name (_lupdf and _lupmf)

2 Likes

Cool, thanks for the hint!