stan-dev / example-models

Example models for Stan
http://mc-stan.org/
771 stars 479 forks source link

leuk example uses poisson_log but does not use log rate #114

Open paciorek opened 7 years ago

paciorek commented 7 years ago

It looks like the use of poisson_log is incorrect, because the expression used (see below) is for the Poisson rate not the Poisson log rate.

Y[i, j] * exp(beta * Z[i]) * dL0[j]  # this is Poisson rate, but used as log rate

In non-deprecated Stan code, the revised code would be:

target += poisson_lpmf(dN[i, j] | Y[i, j] * exp(beta * Z[i]) * dL0[j]);

Or perhaps a sampling statement is cleaner:

dN[i, j] ~ poisson(Y[i, j] * exp(beta * Z[i]) * dL0[j]);
bob-carpenter commented 7 years ago

Thanks much for reporting. We really need to bring all of our old programs up to current standards.

I'd be inclined to use a vectorized sampling statement to make it

dN[i] ~ poisson_log(log_Y[i] + beta * Z[i] + log_dL0);

assuming all the other types are compatible. That assumes log(Y) is defined as log_Y and same for dL0.