# Still confused about how sample_new_levels works in posterior_predict

@paul.buerkner
I have read the following threads and still struggle to understand the differences between “uncertainity”, “gaussian” and “old_levels” optios for sample_new_levels.

Suppose I have a multilevel model y ~ 1 + time + (1 + time|subj); random intercepts and slopes model grouped by subject. I have data on 50 subjects with varying times ranging from 5-15 months each.

I am interested in predicting outcomes for the next 100 subjects for the 40 months; conditional on the posterior distribution.

My understanding is is that if in posterior_predict, sample_new_levels = “gaussian” and ndraws = 1 ; you sample one set of joint posterior samples (fixed, random parameters and Sigma) and then would use a multivariate normal distribution to generate observations for 100 subjects, if ndraws = 2 then the next set of 100 subjects would be generated from a second draw of posterior samples?

However, I am unclear how predictions would be made when sample_new_levels = “uncertainity” and ndraws = 1, is the difference that even though ndraws = 1, the data for 100 new subjects is generated from 100 “joint” draws of posterior samples instead of from 1 draw like above?

Not sure if I realize how “old_levels” works.

Thanks
Jinesh

1 Like

Sorry your question slipped through the cracks!

For `gaussian`, at each posterior iteration, we sample the random effect parameter from the hyperparameters.

For `uncertainty`, at each posterior iteration, we sample the random effect parameter from the random effect parameters of the existing groups at that iteration. Which group we use is randomized across iterations.

These first two options are designed to give a sense of the uncertainty in the value of the random effect parameter for a new level. If sampled a bunch of new levels this way, and plotted the posterior margin for the random term associated with each new level, the plots would be “smeared out” over the full uncertainty implied by the random effect distribution, which would make them easy to pick out if we also plotted the fitted random terms for the original levels (assuming that the original levels all had informative likelihoods).

For `old_levels`, we associate each new level with one of the existing level in a way that persists across iterations, and we use that existing level’s estimates. If we sampled a bunch of new levels this way, and plotted the posterior margin for the random term associated with each new level, the new levels would be impossible to pick out if we also plotted the fitted random terms for the original levels. Indeed, each of the new levels would have a posterior that is identical to one of the old levels.

3 Likes