Plotting the posterior predictive for separate conditions (vs as a whole)

Hi all,

I’m trying to plot my posterior predictive for psychometric functions of 14 separate conditions. The code below only generates the posterior predictive for the aggregate of all conditions. How would I change my code below to plot the posterior predictive for each of the 14 conditions separately?

Thanks much!


This is currently what the posterior predictive looks like:

n_samps <-100
xx <- seq(min(dat.2$norm), max(dat.2$norm), length.out=500)
psi <- matrix(NA, n_samps, length(xx))
i <- 0

for (sn in sample(x=length(fit.samples$lp__), size=n_samps, replace = TRUE)) {
  i<- i + 1
  midpoint <- with(fit.samples, mum[sn] + fA[sn] + sA[sn] + fsA[sn,cn])
  width <- with(fit.samples, mean(muw))
  psi[i,] <- chance_performance + (1 - chance_performance) *

eap_midpoint <- with(fit.samples, mean(midpoint))
eap_width <- with(fit.samples, mean(width))
eap_psi <- chance_performance + (1 - chance_performance) * 
colvec <- grey(pmax(pmin(rnorm(n_samps, mean=.7, sd=.08), 1), 0))
matplot(xx, t(psi), type='l', lty=1, col=colvec, xlab="Intensity", ylab="Psi")

lines(xx, eap_psi, lwd=2)


You want to do posterior predictive checks? Can’t you use bayesplot, where you often have a group = argument one can use?

1 Like