Is there an easy way to convert a stanfit object to a stanreg object?
I am fitting a cross-nested hierarchical model. I wanted to increase my options for priors and in order to improve convergence, used redundant parameters as discussed in Gelman & Hill. So I have a stanfit object from rstan. The model converged and my samples completed relatively quickly. However, I see that there are a lot of additional helper functions [like bayes_R2() or posterior_vs_prior() ] in the rstanarm package. Is there an easy way to convert to a stanreg object, or must I refit my model (and initial attempts at that suggest lose the additional efficiency from the redundant parameters) with stan_lmer()?
Thanks!
No, that it impossible. A stanreg
object is produced by the rstanarm package and contains a stanfit
object produced by rstan. The additional information in the stanreg
object tells R what the model was, which allows it to utilize the functions in the rstanarm package such as posterior_predict
, etc. Otherwise, R has no way of knowing what posterior distribution your stanfit
object pertains to and thus cannot implement appropriate post-estimation methods for it.