I am trying to use rstanarm for plotting posterior predictive distributions and related results. However I receive errors when i use functions such as “yrep = posterior_predict(stanfit, draws = 500)” . The error is:
Error in UseMethod("posterior_predict") : no applicable method for 'posterior_predict' applied to an object of class "stanfit"
while I manually draw my posterior “f” value to a new variable like f_results then I use codes as follow:
'... f_results = subset(draws2, variable="f") %>% as_draws_df() y=standata2$y yrep=f_results[,1:174] ppc_dens_overlay(y, yrep[1:50,])
I kept f_results[,1:174] and drop out the last three column which was related to chain numbers and other stuff. Also y is a one colomn with 174 rows. however when I use ppc_dens_overlay command then i got this error:
Error in validate_yrep(yrep, y) : is.matrix(yrep) is not TRUE
I guess there is something wrong with my yrep which is not defined as matrix by r. Otherwise all the dimensions are correct so why i cannot run it?
Could you kindly advice me for these two errors?