---
title: "Take Home Quiz 2"
author: "Your Name"
date: "Due Tuesday Oct. 22 at 11:00am"
---
There is no time limit, but this quiz should take you about 30-40 minutes.
Place your answers into this markdown document, knit it, and hand in the result as a PDF or Word document.
You may use R, any reference material, and information already available on the internet. Do not work together, do not use AI, and do not get help from anyone but Dr. Clair.
### Problem 1 (10 points)
Here is a stan program:
data {
int Y;
}
parameters {
real pi;
}
model {
Y ~ binomial(10, pi);
pi ~ beta(2, 2);
}
a. What does this program do?
b. If you pass Y=3 as data, what distribution will the simulation results have?
### Problem 2 (10 points)
Explain why grid approximation will not work for models with a large number of parameters.
### Problem 3 (10 points)
Amber Thomas collected data on the ages of actors in teen TV shows released between 2000 and 2021.
We will investigate the question, how old are the actors playing 17-year-olds?
Let $Y$ be the age of an actor playing a 17-year-old on TV. Model $Y$ as a normal rv with unknown mean $\mu$ and sd $\sigma$, as:
* $Y \sim \text{Normal}(\mu, \sigma^2)$
* $\mu \sim \text{Normal}(17, 2^2)$
* $\sigma \sim \text{Gamma(1,1)}$
a. What are the parameters in this model?
b. Is this a conjugate prior model?
c. Explain why the prior on $\mu$ is a reasonable choice.
### Problem 4 (10 points)
The teen actor data is available on our course web page at https://turtlegraphics.org/bayes/data/actor_character_age_difference.csv
As a first step, load the data and filter down to actors with `character_age` 17 which have a valid `actor_age` (some `actor_age` values are missing).
Make a histogram of the actor's ages for actors that have `character_age` equal to 17.
### Problem 5 (10 points)
Use either a grid approximation or MCMC to estimate the posterior distribution of $\mu$ and $\sigma$ for this model, with data given by the 67 actors who portrayed 17-year olds.
Make a plot of the posterior distribution.
Just by looking at your plot, give an estimate of both $\mu$ and $\sigma$ at the mode of the posterior.