class: title-slide <br> <br> .right-panel[ # Posterior Prediction ## Dr. Mine Dogucu Examples from [bayesrulesbook.com](https://bayesrulesbook.com) ] --- class: middle ### Posterior prediction of new outcomes Suppose we get our hands on 20 more artworks. What number would you _predict_ are done by artists that are Gen X or younger? -- - __sampling variability__ - __posterior variability__ in `\(\pi\)`.\index{sampling variability} --- class: middle First, let `\(Y' = y'\)` be the (yet unknown) number of the 20 new artworks that are done by Gen X or younger artists. Thus conditioned on `\(\pi\)`, the randomness in `\(Y'\)` can be modeled by `\(Y'|\pi \sim \text{Bin}(20,\pi)\)` with pdf `$$f(y'|\pi) = P(Y' = y' | \pi) = \binom{20}{ y'} \pi^{y'}(1-\pi)^{20 - y'}$$` -- class: middle `$$f(y'|\pi) f(\pi|(y=14)) \; ,$$` --- <img src="slide-07b-posterior-prediction_files/figure-html/art-pred-1-ch8-1.png" style="display: block; margin: auto;" /> --- class: middle `\(f(y'|(y=14)) = \int_0^1 f(y'|\pi) f(\pi|(y=14)) d\pi\)` -- `\(f(y'|(y=14)) = {20 \choose y'} \frac{\Gamma(110)}{\Gamma(18)\Gamma(92)}\frac{\Gamma(18+y')\Gamma(112-y')} {\Gamma(130)} \text{ for } y' \in \{0,1,\ldots,20\}\)` -- `\(f((y'=3)|(y=14)) = {20 \choose 3}\frac{\Gamma(110)}{\Gamma(18)\Gamma(92)}\frac{\Gamma(18+3)\Gamma(112-3)} {\Gamma(130)} = 0.2217\)` --- <img src="slide-07b-posterior-prediction_files/figure-html/art-pred-2-ch8-1.png" style="display: block; margin: auto;" /> --- Let `\(Y'\)` denote a new outcome of variable `\(Y\)`. Further, let pdf `\(f(y'|\pi)\)` denote the dependence of `\(Y'\)` on `\(\pi\)` and posterior pdf `\(f(\pi|y)\)` denote the posterior plausibility of `\(\pi\)` given the original data `\(Y = y\)`. Then the posterior predictive model for `\(Y'\)` has pdf `$$f(y'|y) = \int f(y'|\pi) f(\pi|y) d\pi \; .$$` In words, the overall chance of observing `\(Y' = y'\)` weights the chance of observing this outcome under _any_ possible `\(\pi\)` ( `\(f(y'|\pi)\)` ) by the posterior plausibility of `\(\pi\)` ( `\(f(\pi|y)\)` ). --- ```r head(art_chains_df, 3) ``` ``` ## pi ## 1 0.1300708 ## 2 0.1755003 ## 3 0.2214110 ``` --- ```r set.seed(84735) # Predict a value of Y' for each pi value in the chain art_chains_df <- art_chains_df %>% mutate(y_predict = rbinom(length(pi), size = 20, prob = pi)) ``` -- ```r head(art_chains_df, 3) ``` ``` ## pi y_predict ## 1 0.1300708 4 ## 2 0.1755003 4 ## 3 0.2214110 4 ``` --- ```r ggplot(art_chains_df, aes(x = y_predict)) + stat_count() ``` <img src="slide-07b-posterior-prediction_files/figure-html/unnamed-chunk-7-1.png" style="display: block; margin: auto;" />