Custom pdf with 2 variables

I want to create a custom lpdf function which takes 2 variables and 3 parameters

real dist_lpdf(real y1, int y2, …)

Just to make it more interesting, one variable is continuous and the other is discrete, but I can make y2 continuous as a hack.

When I do the

target += dist_lpdf(y1, y2 | …) stan expects a | after y1.

Do I need to make y1 and y2 into a vector?

1 Like

Ok I think I am going with

real dist_lpdf(real[] y, …)

and

target += dist_lpdf({y1, y2}| …)

2 Likes

Yes, Stan’s syntax is not particularly suited for such a use case, but using real[] as argument is sensible. Alternatively, you can just drop the _lpdf suffix and Stan will then not enforce any | in your calls (but the generated C++ code will be almost the same).

Best of luck with your model!