Plots ppc_intervals-style for test set

Hi!

Did anyone develop any package/function to show plots like ppc_intervals or ppc_intervals_grouped with predictions outside the training set? Especially for the case when we have time in x.

Thank you!

I think if you have a matrix of posterior predictions for new data, then you just pass that matrix and vector of outcomes to the corresponding function in the bayesplot package. But your model should not badly overfit the data you condition on, which can be assessed via the functions returned by

bayesplot::available_ppc(pattern = "loo")
1 Like

Thank you!

It’s just that the vector of outcomes have to be the same length than the yrep. I’ve got this so far:

ppc_intervals_grouped(y=db$y,
yrep=cbind(post$yrep,post$yproj),
x=c(db$day,yproj$day),
group=c(as.character(db$reg),as.character(yproj$reg)))

I could put the expected means with db$y to get the plot, but then I am not able to change the colour for the projection.

That always is the case. I’m not sure I understand. Why the cbind(post$yrep, post$yproj)?

post$yproj are the matrix of posterior predictions for unobserved data (future time). In order to extrapolate the model in time (with ppc_intervals_grouped), I have to add the y_projected posteriors as well as “observations”, which I decided to be the expected means. Although, I can’t play with the format of both matrices, or I don’t know how yet. I only added a dashed line to split them:

image

ppc_intervals_grouped(y=c(db$y,summary$yproj_means),
yrep=cbind(post$yrep,post$yproj),
x=c(db$day,yproj$day),
group=c(as.character(db$reg),as.character(yproj$reg)))