Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different rhat for Rstan and CmdStanR #286

Closed
Alex-Cremers opened this issue Jul 16, 2022 · 1 comment
Closed

Different rhat for Rstan and CmdStanR #286

Alex-Cremers opened this issue Jul 16, 2022 · 1 comment

Comments

@Alex-Cremers
Copy link

Hello,

I have a model fitted with cmdstanR which did not converge properly. The Rhat for one of the parameters is 1.33 when I look at model_fit$summary(), however if turn the model into a stanfit object, the summary now indicates a Rhat of 1.48.

I first thought that the two summary functions call different rhat functions, but the following lines do show the same discrepancy:

bayesplot::rhat(model_fit,pars="alpha")
rstan_fit = rstan::read_stan_csv(model_fit$output_files())
bayesplot::rhat(rstan_fit,pars="alpha")

Is there a reason why this could happen, or it it a bug? If needed I can upload the draws for this particular parameter. Using posterior::rhat on the matrix of draws returns 1.33, as with the summary method for the CmdStanFit object.

Best regards,

@jgabry
Copy link
Member

jgabry commented Nov 14, 2022

Hi @Alex-Cremers, sorry nobody responded until now!

Internally bayesplot::rhat uses the values computed by CmdStanR and RStan (bayesplot doesn't actually compute anything itself), so the issue is that CmdStanR's summary method is using posterior's Rhat whereas RStan's summary method is still using the older version of Rhat. After you convert model_fit to rstan_fit the Rhat values that are used will come from RStan's summary method and will be different.

Sorry again for the (very) slow reply!

@jgabry jgabry closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants