Issue with bridgesampling::bridge_sampler()

Hi, I am having issues with the function:

brs.reference <- bridgesampling::bridge_sampler(stanfit_model = stan.fit)

Where stan.fit is a stan fit class object obtained by running my model using the stan() function. The error message I get is that Error in .local(object, ...) : the model object is not created or not valid. (the stan fit object is good and I use it for other tasks, so it is not inherently flawed).

I tried to debug the code with ChatGPT and playing around with it, but to no avail. Anyone has any suggestion on what I can do?

Not sure if this explains your error message, but just to check:
In order to pass a stan_fit object directly to the bridge_sampler function, the Stan model needs to be implemented in such a way that it includes all proportionality constants. So for example using

target += normal_lpdf(x | 0, 1);

instead of

x ~ normal(0, 1);

(This is mentioned in section 4 of the bridgesampling package paper)

Is this the case for your model?

1 Like