'R-hat against iterations RStan

I am trying to generate a similar plot as below to show the change in R-hat over iterations: enter image description here

I have tried the following options :

  • summary(fit1)$summary : gives R-hat all chains are merged
  • summary(fit1)$c_summary : gives R-hat for each chain individually

Can you please help me to get R-hat for each iteration for a given parameter?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source