1. Posterior prediction
Suppose we aren't just interested in the general trends between weight and height. We'd also like to *predict* weight for a given height. We can!
2. Posterior trend
Recall the likelihood structure for the Bayesian regression model of weight $Y$ by height $X$. In earlier exercises, you simulated the posterior model of $y$-intercept $a$, slope $b$, and residual standard deviation $s$.
3. Posterior trend
Based on these simulation results, you estimated the posterior mean trend to have an intercept of -104.038 kg and slope of 1.012 kg/cm.
4. Posterior trend when height = 180 cm
Let's zero in on the trend in weight among 180 cm tall adults.
Plugging 180 in for $X$ in the posterior mean trend indicates that the mean weight among this group is roughly 78 kg. Yet uncertainty in the parameter values trickles down to uncertainty in this calculation of trend.
5. Estimating posterior trend when height = 180 cm
Mainly, the original calculation utilizes only the posterior means of the intercept and slope, -104.038 and 1.012.
However, in our 100,000 iteration `weight_chains` RJAGS simulation, we observed 100,000 unique, plausible sets of intercept and slope values, $a$ and $b$.
6. Estimating posterior trend when height = 180 cm
We can calculate the unique trend in weight among 180 cm tall adults under each regression parameter set. These trends are stored here as `m_180`.
For example, under the first set with an intercept of -113.9029 kg and slope of 1.0725 kg/cm, the mean weight among 180 cm adults is roughly 79.148 kg.
7. Posterior distribution of trend
A density plot indicates that the 100,000 `m_180` values are Normally distributed around 78.122, the mean weight calculated from the posterior mean regression line. The variability around this trend reflects our uncertainty in this calculation.
8. Credible interval for posterior trend
Again, we can express this uncertainty using a credible interval. Here there's a 95% posterior chance that the mean weight among 180 cm tall adults is between 76.95 and 79.24 kg.
9. Visualizing posterior trend
The little vertical red line represents this credible interval on a scatterplot of weight vs height. Though this credible interval captures our uncertainty in the weight *trends* among 180 cm tall adults, it certainly doesn't reflect our uncertainty in individual deviations from this trend.
10. Posterior trend vs posterior prediction
So let's switch our goal: instead of understanding the mean weight among 180 cm tall adults, let's *predict* the weight of a *specific* 180 cm tall adult.
The calculation of the posterior prediction is the same as for the posterior trend, we simply plug in 180. Yet, given the degree of individual deviation from the trend, there's undoubtedly more uncertainty in the prediction.
11. Predicting weight when height = 180 cm
To this end, we must incorporate residual standard deviation into our prediction. The likelihood model specifies that at a height of 180, weights are Normally distributed around the trend $m_{180}$ with residual standard deviation $s$. The first three simulated sets of posterior plausible $s$ and $m_{180}$ values are shown here.
We can simulate a weight prediction under the first set by taking a random draw from a Normal distribution with mean 79.15 kg and standard deviation 8.77 kg.
Similarly, we can simulate weight predictions under the other 2 sets of $s$ and $m_{180}$ values.
12. Posterior predictive distribution
Repeating this simulation using each of the 100,000 sets of posterior plausible values of $s$ and $m_{180}$ produces 100,000 unique predictions of weight for a 180 cm tall adult. A density plot of these predictions, an approximation of the posterior predictive distribution, is shown here.
13. Posterior prediction interval
The corresponding 95% posterior prediction interval indicates that there's a 95% chance that the weight of a given 180 cm tall adult is between 59.68 and 96.25 kg.
As anticipated, this interval is much wider than the credible interval for the mean weight among 180 cm tall adults since it accommodates for individual deviation from the trend.
14. Let's practice!