Largest Rhat is NA when one parameter is fixed to a constant

No, as the diagnostic code doesn’t know whether you fixed it or whether the sampling is stuck. Longer explanation and comment improving the warning below.

The problem with parameters fixed to a constant is that from a finite number of posterior draws that all have the same value, we can’t distinguish between a parameter that is really a constant and a parameter which is logically not constant, but the chain was stuck on one value. The stored information in the posterior draws doesn’t include information if some parameter is logically constant or something which could have different values in a much longer chain.

Probably the most common example would when in generated quantities an indicator function is used for counting how many times some logical condition holds. For example, if we want to estimate the probability that theta>0, we can have in generated quantities

int theta_gt_zero = theta>0;

If the p(theta>0) is very close to 0 or 1 but not equal to 0 or 1, we could still see just 0’s or 1’. Based on just those constant looking values, we can’t then know how efficient MCMC is for estimating that probability (except with additional information).

Another example would be if alpha is continuous and in logit prob scale. It is then possible that draws of alpha all have different values, but due to the limited floating point accuracy inv_logit(alpha) can have all constant draws.

Because of this ambiguity we decided to report NA for Rhat, ESSs and MCSEs, if all posterior draws for a parameter are equal. In case of NA, then the user needs to use the additional information to check whether the parameter is logically constant or use some other information to check the convergence and mixing if it’s not logically constant (e.g. in the above example check the convergence and efficiency for theta).

The warning you see is based on the new code, but it seems what you print for k[1] is based on the old code (it helps if you tell which function you call, form which package, and the package version). I recommend to use posterior package GitHub - stan-dev/posterior: The posterior R package which has the latest code.

See more discussion on this at

  • The warning message should be modified to give more informative message when there are NAs.
  • Also the documentation for rhat* and ess* functions should be edited to include comment why output can have NA.

I made issues on these Document edge case behavior for summary functions (e.g. rhat and ess) · Issue #70 · stan-dev/posterior · GitHub and Improve convergence diagnostic message for NA · Issue #769 · stan-dev/rstan · GitHub

EDIT: added example where draws are apparently constant due to the limited floating point accuracy.
EDIT2: added the issue links