Hello all,
After reading the release notes of Stan 2.25 (!!) I am suddenly unsure if I am using reduce_sum
correctly.
For every reduce_sum
transition, I declare the accumulated log probability (lp
) to be 0 - lp=0
and accumulate it using lp += ....
until I return it. Please see the simplified example below:
functions {
real partial_sum(.....) {
real lp = 0;
lp += normal_lpdf(...);
lp += bernoulli_lpmf(...);
lp += wiener_lpdf(...);
.
.
return lp;
}
}
.
.
.
model {
target += reduce_sum(partial_sum, .......);
}
Is this correct? Or should I pass target +=
into reduce_sum
? Or am I completely off?
Thank you!