How make predictions for individual not in training data in multilevel model


I was told by a professor that an advantage of bayesian multilevel models for modelling y_{it} = \alpha_{i} + \beta_{i}x_{it} +\varepsilon_{it} compared to other (machine learning and frequentist type of methods) is that we also can make predictions for individuals not in the training data, since we know the distribution of \alpha_{i} and \beta_{i}. However, I do not know how to make this work in practice. I have estimated a multilevel model, which works fine. But how can I make a prediction for an individual not in the training set? How should I use the distributions for \alpha_{i} \sim N(\alpha, \sigma_{\alpha}) and \beta_{i} \sim N(\beta, \sigma_{\beta}) for this?



First, if you are using brms, it lets you do this automatically with the allow_new_levels argument to the predict function. If you are not the overall idea is that to get a single sample for a new individual is to:

  1. Take a single sample from your posterior, this gives you values for \alpha, \sigma_\alpha, \beta, \sigma_\beta
  2. Draw \alpha_{new} \sim N(\alpha, \sigma_{\alpha}) and \beta_{new} \sim N(\beta, \sigma_{\beta})
  3. Draw the noise term
  4. Compute y

Repeat this to get as many samples as you need.