class: title-slide <br> <br> .right-panel[ # Sequentiality in Bayesian Analyses ## Dr. Mine Dogucu Examples from [bayesrulesbook.com](https://bayesrulesbook.com) ] --- ## Sequential Analysis In a sequential Bayesian analysis, a posterior model is updated incrementally as more data comes in. With the introduction of each new piece of data, the previous posterior model reflecting our understanding prior to observing this data becomes the new prior model. --- ## Let's time travel to the end of 1970 `\(\pi \sim Beta(14,1)\)` -- ```r bechdel %>% filter(year == 1970) ``` ``` ## # A tibble: 1 x 3 ## year title binary ## <dbl> <chr> <chr> ## 1 1970 Beyond the Valley of the Dolls PASS ``` --- ## The Posterior ```r summarize_beta_binomial(14, 1, y = 1, n = 1) ``` ``` ## model alpha beta mean mode var sd ## 1 prior 14 1 0.9333333 1 0.003888889 0.06236096 ## 2 posterior 15 1 0.9375000 1 0.003446691 0.05870853 ``` --- ### At the end of 1971 `\(\pi \sim Beta(15,1)\)` -- ```r bechdel %>% filter(year == 1971) ``` ``` ## # A tibble: 5 x 3 ## year title binary ## <dbl> <chr> <chr> ## 1 1971 Escape from the Planet of the Apes FAIL ## 2 1971 Shaft FAIL ## 3 1971 Straw Dogs FAIL ## 4 1971 The French Connection FAIL ## 5 1971 Willy Wonka & the Chocolate Factory FAIL ``` --- ## The Posterior ```r summarize_beta_binomial(15, 1, y = 0, n = 5) ``` ``` ## model alpha beta mean mode var sd ## 1 prior 15 1 0.9375000 1.0000000 0.003446691 0.05870853 ## 2 posterior 15 6 0.7142857 0.7368421 0.009276438 0.09631427 ``` --- ### At the end of 1972 `\(\pi \sim Beta(15,6)\)` -- ```r bechdel %>% filter(year == 1972) ``` ``` ## # A tibble: 3 x 3 ## year title binary ## <dbl> <chr> <chr> ## 1 1972 1776 FAIL ## 2 1972 Pink Flamingos PASS ## 3 1972 The Godfather FAIL ``` --- ## The Posterior ```r summarize_beta_binomial(15, 6, y = 1, n = 3) ``` ``` ## model alpha beta mean mode var sd ## 1 prior 15 6 0.7142857 0.7368421 0.009276438 0.09631427 ## 2 posterior 16 8 0.6666667 0.6818182 0.008888889 0.09428090 ``` --- class: middle <div align="center"> | Time | Data | Model | |---------------------|--------------|-------------| | before the analysis | NA | Beta(14,1) | | at the end of 1970 | Y = 1, n = 1 | Beta(15,1) | | at the end of 1971 | Y = 0, n = 5 | Beta(15, 6) | | at the end of 1972 | Y = 1, n = 3 | Beta(16,8) | --- class: middle <div align="center"> ## Data Order Invariance | Time | Data | Model | |---------------------|--------------|------------| | before the analysis | NA | Beta(14,1) | | 1972 | Y = 1, n = 3 | Beta(15,3) | | 1971 | Y = 0, n = 5 | Beta(15,8) | | 1970 | Y = 1, n = 1 | Beta(16,8) | --- class: middle <div align="center"> ## What if we observed all the data at once? | Time | Data | Model | |---------------------|--------------|------------| | before the analysis | NA | Beta(14,1) | | 1970 | Y = 1, n = 1 | | |1971 | Y = 0, n = 5 | | |1972 | Y = 1, n = 3 | | | Total | Y = 2, n = 9 | | --- ```r summarize_beta_binomial(14, 1, y = 2, n = 9) ``` ``` ## model alpha beta mean mode var sd ## 1 prior 14 1 0.9333333 1.0000000 0.003888889 0.06236096 ## 2 posterior 16 8 0.6666667 0.6818182 0.008888889 0.09428090 ``` --- Let `\(\theta\)` be any parameter of interest with prior pdf `\(f(\theta)\)`. Then a __sequential analysis__ in which we _first_ observe a data point `\(y_1\)` and _then_ a second data point `\(y_2\)` will produce the same posterior model of `\(\theta\)` as if we _first_ observe `\(y_2\)` and *then* `\(y_1\)`: `$$f(\theta | y_1,y_2) = f(\theta|y_2,y_1)\;.$$` Similarly, the posterior model is invariant to whether we observe the data _all at once_ or _sequentially_.