Describe the bug
The attached model b1.stan works great when I call partial_sum directly as in lines 90-94. If I try the same using reduce_sum then I get lots of errors like,
Chain 4 Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Chain 4 Exception: inv_gamma_lpdf: Random variable is nan, but must not be nan! (in '/tmp/RtmpqaKZHp/model-9bc7b5d5debeb.stan', line 76, column 2 to column 25)
This happens even with set_num_threads(1).
I compile the model with,
b1 <- cmdstan_model("b1.stan", threads=TRUE, quiet=TRUE)
What am I doing wrong? Do I need to provide a minimal reproducible example, or is this a known bug?
Operating system
Ubuntu focus amd64, gcc 9.3.0-10ubuntu2
CmdStanR version number
0.0.0.9000 with Stan 2.23.0
@wds15 do you maybe see anything wrong on first glance here?
Hmm, how recently did you install cmdstanr? It might be that you need to do cpp_options = list(stan_threads = TRUE) instead of threads=TRUE (if you installed it within the past few days). I don't know if that's the issue, but if it's not then I think this is more likely a issue with stan than the cmdstanr wrapper .
reduce_sum works even with STAN_THREADS off (just not faster), so its definitely a stan/math issue or a model issue. If Sebastian sees anything we can fix this quickly otherwise we can transfer the issue to math.
ok makes sense. thanks @rok-cesnovar
This is again an issue with wrong error messages . You Index obs with ii, but that index is running along the large index and not just the sub slice as it has to. So replace the ii index when accessing things from obs with an index which starts from 1... so it鈥檚 ii-start+1
Yeah, works now. Thanks!
Most helpful comment
This is again an issue with wrong error messages . You Index obs with ii, but that index is running along the large index and not just the sub slice as it has to. So replace the ii index when accessing things from obs with an index which starts from 1... so it鈥檚 ii-start+1