Get startedGet started for free

Exercise 8 - Estimate the Posterior Distribution

The CLT tells us that our estimate of the spread \(\hat{d}\) has a normal distribution with expected value \(d\) and standard deviation \(\sigma\), which we calculated in a previous exercise.

Use the formulas for the posterior distribution to calculate the expected value of the posterior distribution if we set \(\mu = 0\) and \(\tau = 0.01\).

This exercise is part of the course

HarvardX Data Science Module 4 - Inference and Modeling

View Course

Exercise instructions

  • Define \(\mu\) and \(\tau\)
  • Identify which elements stored in the object results represent \(\sigma\) and \(Y\)
  • Estimate B using \(\sigma\) and \(\tau\)
  • Estimate the posterior distribution using B, \(\mu\), and \(Y\)

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# The results` object has already been loaded. Examine the values stored: `avg` and `se` of the spread
results

# Define `mu` and `tau`
mu <- 0
tau <- 0.01

# Define a variable called `sigma` that contains the standard error in the object `results`


# Define a variable called `Y` that contains the average in the object `results`


# Define a variable `B` using `sigma` and `tau`. Print this value to the console.


# Calculate the expected value of the posterior distribution
Edit and Run Code