Beta proportion

Hi,

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?

y_non_zeroK=[0.1,0.1,0.1,0.1,0.1,0.5,0.2,0.2,0.1,0.2,0.2,0.3,0.3,0.2,0.5,0.4,0.2,0.5,0.2,0.2,0.1,0.4,0.3,0.1,0.2,0.1,0.5,0.6,0.1,0.3,0.1,0.7,0.1,0.4,0.5,0.1,0.1,0.2,0.2,0.3,0.1,1,1,0.4,0.4,0.3,0.2,0.1,0.3,0.7,0.9,0.6,0.2,0.2,0.2,0.5,0.5,0.3,0.2,0.4,0.3,0.4,0.4,0.1,0.1,0.1,0.1,0.2,0.2,0.2,0.2,0.1,0.5,0.6,0.1,0.2,0.3,0.1,0.3,0.3,0.1,0.1,0.1,0.1,0.1,0.2,0.1,0.2,0.1,0.1,0.1,0.3,0.1,0.3,0.1,0.1,0.2,1,0.3,0.3,0.4,0.2,0.2,0.3,0.9,0.1]
YTK=[0.31778,0.378878,0.35223,0.400559,0.309762,0.27518,0.276434,0.292786,0.304977,0.291332,0.273778,0.298426,0.304069,0.313281,0.321765,0.315068,0.262522,0.272907,0.399835,0.279331,0.34582,0.27165,0.318618,0.291886,0.365496,0.364028,0.341535,0.340971,0.269317,0.263094,0.381952,0.415228,0.345078,0.421409,0.416051,0.414021,0.276269,0.255349,0.256636,0.270528,0.287021,0.24796,0.249172,0.24838,0.274321,0.354062,0.360428,0.422444,0.329845,0.363724,0.377563,0.392534,0.413525,0.416063,0.396899,0.415612,0.414218,0.316014,0.2627,0.279848,0.305756,0.416987,0.327383,0.245542,0.401821,0.404858,0.380582,0.358008,0.316887,0.329617,0.369244,0.361945,0.274203,0.271617,0.287164,0.289413,0.269714,0.271704,0.29253,0.266372,0.420094,0.416374,0.246409,0.42124,0.324575,0.298979,0.303155,0.31649,0.293151,0.348665,0.416767,0.305236,0.270435,0.266232,0.330932,0.35702,0.359144,0.396277,0.380668,0.383256,0.30733,0.315991,0.26427,0.260667,0.381119,0.414834]
sigma=0.66081

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 https://github.com/stan-dev/math/issues/1413. 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 = f.read()
with open('fixed.stan', 'w') as f:
  f.write(s.replace('\r', '\r\n'))
2 Likes

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