Parsing error when using lupmf


I am using pystan to specify my stan model. In the middle, I want to try poisson_log_lupmf() function but I kept receiving the same syntax error message over and over when compiling the syntax:


To reproduce the error, here is the stan code from my end.

 real beta0;
 real beta1;
transformed parameters{
 real lp;
 lp = poisson_log_lupmf(5|beta0+2*beta1);
 beta0 ~ normal(0,10);
 beta1 ~ normal(0,10);
 target += lp;

Really appreciate it if someone could help with this issue.

PyStan 2 does not support _lupmfs. You must either use CmdStanPy or upgrade to PyStan 3 (released a few days ago but note that it is backwards-incompatible).
Also note that _lupmf only works in model block. It’s not allowed in transformed parameters.

Thank you for your explanation. I installed pystan by the instruction from stan official website so I am not sure if the version is 2 or 3. Putting lupmf function() in the transformed parameters block was not in my original code but thank you for letting me know the rule of using lupmf. My original purpose was to define a set of functions using lupmf and then contionally apply them in the transformed parameters block so I am wondering if it still would not work since lupmf only works in the model block.

If you installed it before Thursday then it’s PyStan 2. And I’m pretty sure PyStan 3 would say something more informative than PARSER EXPECTED: "(".

You can use _lupmf inside a function but if that function is called outside model block then it gives the same result as _lpmf.

I see. Thank you so much! Have a nice day!