Processing math: 53%
+ - 0:00:00
Notes for current slide
Notes for next slide

Shiny

Colin Rundel

2019-11-25

1 / 8

2 / 8

Shiny

  • is a framework for writing web apps in R

  • easiest way to create interactive tools using R

  • can be run locally in RStudio, hosted on RStudio's shinyapps.io or your own server, or even embedded in RMarkdown documents.

3 / 8

Shiny Resources

All of these can be found at RStudio's Shiny homepage:

4 / 8

A "Fair" Coin and the Beta-Binomial model

Let's imagine a situation where I have a coin that I claim is fair, you are less certain - you can ask me to flip the coin n times and we will record the number of "heads" as x. After this experiment what should you believe about the fairness of my coin?

5 / 8

A "Fair" Coin and the Beta-Binomial model

Let's imagine a situation where I have a coin that I claim is fair, you are less certain - you can ask me to flip the coin n times and we will record the number of "heads" as x. After this experiment what should you believe about the fairness of my coin?


We can model this using the conjugate beta-binomial model,

π(p)Beta(α,β)x|pBinom(p,n) it then follows that p|xBeta(α+x,β+Nx)

5 / 8

Live Demo

6 / 8

Approximate Bayesian Computation (ABC)

Offered without any theory or proof, consider the following algorithm:

  1. Sample m values from each of the given prior distribution(s), \boldsymbol{\theta}^{(m)}.

  2. For each of the m draws, simulate the data from the assumed data generative process, \boldsymbol{x}^{(m)}.

  3. If the simulated data is sufficient close to the observed data, keep \boldsymbol{\theta}^{(m)}.

  4. The distribution of the kept \boldsymbol{\theta}^{(m)}s will approximate the posterior distribution \boldsymbol{\theta}|\boldsymbol{x}.

7 / 8

Beta-Binomial ABC

Our particular use case provides a straight forward application of this method,

8 / 8

Beta-Binomial ABC

Our particular use case provides a straight forward application of this method,

  1. Draw from the prior:
    p = rbeta(m, alpha, beta)
8 / 8

Beta-Binomial ABC

Our particular use case provides a straight forward application of this method,

  1. Draw from the prior:
    p = rbeta(m, alpha, beta)
  1. Simulate the data:
    x_sim = rbinom(m, n, p)
8 / 8

Beta-Binomial ABC

Our particular use case provides a straight forward application of this method,

  1. Draw from the prior:
    p = rbeta(m, alpha, beta)
  1. Simulate the data:
    x_sim = rbinom(m, n, p)
  1. Keep the matches:
    abc_post = p[x_sim == x]
8 / 8

Beta-Binomial ABC

Our particular use case provides a straight forward application of this method,

  1. Draw from the prior:
    p = rbeta(m, alpha, beta)
  1. Simulate the data:
    x_sim = rbinom(m, n, p)
  1. Keep the matches:
    abc_post = p[x_sim == x]



Why do we care?

8 / 8

2 / 8
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow