CmdSTAN and posterior prediction

#1

Is there a CmdSTAN equivalent to rstanarm’s posterior_predict() function? I am trying to get the median predicted value per-observation without assuming it to be a function of linear predictors. Thanks!

1 Like

#2

You would have to do the posterior prediction in the generated quantities block of the (or a in 2.19) Stan program.

0 Likes

#3

Thanks! I want to make sure the predictions account for true variance in the outcome. If I add a line like:
real l_pred = b_Intercept + dot_product(means_X, b);
am I properly doing so, or is that just going to give me the linear prediction?

0 Likes

#4

That is just the linear predictor. Add a draw from the normal distribution with standard deviation sigma too that (assuming you are using a normal likelihood) to get a draw from the posterior predictive distribution.

0 Likes

#5

Thank you! So would this be what I’m looking for?
real l_pred; l_pred = normal_rng(beta[1] + beta[2] * varA + beta[3] * varB + beta[4] * varC, sigma);

0 Likes

#6

Yeah. You can just do real l_pred = ...;. You don’t have to declare things separately from their definitions.

0 Likes

#7

Awesome. Thanks again!

0 Likes