6 Day 6 (February 6)

6.1 Announcements

  • Please read (and re-read) Ch. 4 and 6 in BBM2L book.

  • Final project is posted

  • Questions about activity 2?

  • Selected questions/clarifications from journals

6.2 Building our first statistical model

  • The backstory
  • Building a statistical model using a Bayesian approach
    • Specify (write out) the likelihood/data model
    • Specify the parameter model (or prior) including hyper-parameters
    • Select an approach to obtain the posterior distribution
      • Analytically (i.e., pencil and paper)
      • Deterministic numerical algorithm
      • Simulation-based or stochastic algorithm (e.g., Metropolis-Hastings, MCMC, importance sampling, ABC, etc)

6.3 Monte Carlo Integration

  • Deterministic vs stochastic methods to approximate integrals

    • Work well for high-dimensional multiple integrals
    • Easy to program
  • Monte Carlo integration

    • \[\begin{eqnarray} \text{E}(g(y)) &=& \int g(y)[y|\theta]dy\\ &\approx& \frac{1}{Q}\sum_{q=1}^{Q}g(y_q) \end{eqnarray}\]
    • Examples:
    1. \[\text{E}(y) = \int_{-\infty}^\infty y\frac{1}{\sqrt{2\pi\sigma^2}}\textit{e}^{-\frac{1}{2\sigma^2}(y - \mu)^2}dy\]
    y <- rnorm(n = 10^6, mean = 2, sd = 3)
    mean(y)
    ## [1] 1.997254
    1. \[\text{E}((y-\mu)^2) = \int_{-\infty}^\infty (y-\mu)^2\frac{1}{\sqrt{2\pi\sigma^2}}\textit{e}^{-\frac{1}{2\sigma^2}(y - \mu)^2}dy\]
    y <- rnorm(n = 10^6, mean = 2, sd = 3)
    mean((y - 2)^2)
    ## [1] 9.001411
    1. \[\text{E}(\frac{1}{y} ) = \int_{-\infty}^\infty \frac{1}{y}\frac{1}{\sqrt{2\pi\sigma^2}}\textit{e}^{-\frac{1}{2\sigma^2}(y - \mu)^2}dy\]
    y <- rnorm(n = 10^6, mean = 2, sd = 4)
    mean(1/y)
    ## [1] -0.5539893
  • Questions about activity 2?

  • Live example using bat model