This is because the pp_check() function needs to either take a vector of observed outcomes y, or an R object that has the pp_check() method defined for extracting the needed quantities. This second approach is generally used for packages like rstanarmor brms where the variable names for each of the quantity types (observed/predicted/etc.) are fixed. This isn’t the case for generic Stan models fitted through rstan, since the variable names are arbitrarily set by the user.

For using pp_check with a generic Stan model, you’ll need to provide the reference y values to pp_check() instead of the model object (m1priorpred)

Error in pp_check(readscore, y_sim, ppc_dens_overlay) :
object 'readscore' not found

You haven’t defined readscore in your R environment, so pp_check doesn’t know what to use. I can see you’ve defined it in your data.list, but not as an object by itself.

Thanks again for your thoughtful replies. Your suggestion seemed to help. The only problem is that the ppc_dens_overlay plots seem strange. I have not had this problem before. Specifically, I tried to approaches to plot the prior distribution

In both cases, get a plot that looks like this one attached Rplot.pdf (189.1 KB)

I’ve used this second approach many times with no issues for posterior predictive checks, but I can’t seem to get the prior predictive distribution to overlay the outcome distribution.

Because you have a very vague prior on mu, but a much more reasonable prior on sigma:

mu ~ normal(0,200);
sigma ~ normal(0,5);

This means that mu can take on very different values from iteration-to-iteration, but that the estimates within a given iteration will be fairly similar (as the sigma is smaller). This is what the ppc_dens_overlay plot is showing, that location parameter for each iteration is very different (the density curves are distributed along the x-axis), but that the scale parameter is comparatively small (the density curves are very narrow).

So this is a case where the plot is demonstrating that your priors are not a good match for the data