stan-dev / posteriordb

Database with posteriors of interest for Bayesian inference
161 stars 26 forks source link

PyMC3 eight school example #247

Closed xidulu closed 1 year ago

xidulu commented 1 year ago

tau, the scale parameter should lie on the positive real value space therefore it should be HalfCauchy or be transformed through exponential function?

https://github.com/stan-dev/posteriordb/blob/master/posterior_database/models/pymc3/eight_schools_noncentered.py#L14

MansMeg commented 1 year ago

Yes. You are right. Im not very good with pymc3. If you can add a PR that would be great.

I think you should use exp since that is what stan is doing and then we can check that we get the same log density for models both in pymc3 and stan.

xidulu commented 1 year ago

@MansMeg Happy to open a PR to fix it, but I am not sure how to check the equivalence of log_density, could you provide some instruction on it?

Thanks

MansMeg commented 1 year ago

Are you running PyStan? Then you could just input some random parameter values for both the stan and the pymc3 model. They should return exactly the same value of the log density. See here on the log_prob in rstan. https://mc-stan.org/rstan/reference/stanfit-method-logprob.html

xidulu commented 1 year ago

@MansMeg Thanks! I will have a look

MansMeg commented 1 year ago

Hi!

I close this issue for now. Just reopen it if you have further questions.