Beta proportion


I am trying to use beta_proportion_lpdf but always get a bogus message “ran beyond end of program in trace()”. Eventually I ended up with using expose_stan_functions with lots of print statements (I am not sure if this is a good way to debug) and found that beta_proportion_lpdf(y_non_zeroK | YTK, sigma) gives Inf with below numbers. Can somebody please help?


1 Like

y_non_zeroK must be strictly less than 1 and greater than zero. There are a couple elements that are 1. That’s evaluating to infs.

Looks like there’s a bug in the implementation which I think is why you’re not getting helpful error messages. Just made an issue Thanks for reporting!

1 Like

My fault. I am passing 1. Still it should return -inf per doc.

1 Like

I am using MPI. The error actually is below. I am supplying feasible initial values using init. Is it possible somehow to debug why it is breaking up?

Unrecoverable error evaluating the log probability at the initial value.
ran beyond end of program in trace()
ran beyond end of program in trace()

1 Like

As discussed in the other thread that “ran beyond end of program” message happens because Stan compiler handles MacOS-style (or whatever) line endings incorrectly. I think you can fix them with this python script.

with open('model.stan', 'r') as f:
  s =
with open('fixed.stan', 'w') as f:
  f.write(s.replace('\r', '\r\n'))

It did the job. Can I do the same in R?

Thanks a lot for this workaround. I was trying to debug this weird message for quite a while. Now my stan code is running.

The bug has already been fixed upstream, it will be in the next release! :)

1 Like