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!

# CmdSTAN and posterior prediction

**bgoodri**#2

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

**bardach**#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?

**bgoodri**#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.

**bardach**#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);`

**bgoodri**#6

Yeah. You can just do `real l_pred = ...;`

. You don’t have to declare things separately from their definitions.