library(tidyverse)
library(juanr)Problem Set 7: Choosing an Estimator
Due: Monday, November 16 by 11:59 PM. Email both your .qmd and your rendered .html to Max Welch (mwelch@ucdavis.edu).
This set leans on the R you learned at Quant Camp. When you get stuck on filtering, grouping, or plotting, go back to the Quant Camp materials. They’re the fastest way to get unstuck.
Use AI the way people used Google, R’s help pages, and Stack Overflow before AI: ask precise, limited questions to get unstuck on part of a question. Passing off AI-generated work wholesale as your own is not allowed. See the syllabus and the Department’s policy on generative AI.
Format: Write your answers in one Quarto document, saved in the sets/ folder of your course project. Start it with this header, so the HTML renders as one self-contained file:
---
title: "Problem Set 7"
author: "Your name"
format:
html:
embed-resources: true
---Your document should read as a short report: brief prose explaining your reasoning, not just code and output.
Libraries you will need:
Parts marked Methods portfolio are required if you plan to choose methods as a subfield. They’re optional, and recommended, for everyone else.
Question 2: When a biased estimator wins
Two pollsters are estimating a candidate’s share of the vote in a district, and the true share is 50%. Each poll is one draw from its pollster’s sampling distribution.
- Pollster A is unbiased. Its estimates have a standard deviation of 4 points.
- Pollster B has a “house effect”: its estimates run 2 points too high on average. But it uses a better sampling method, and its estimates have a standard deviation of only 2 points.
Do this question by hand.
Compute each pollster’s bias, variance, and mean squared error.
Which pollster’s estimate typically lands closer to the truth? By about how much? Explain why a biased estimator can sometimes beat an unbiased one.
Pollster A can afford a bigger sample. Increasing the sample size by a factor of \(k\) divides the variance by \(k\) and leaves the bias alone. How many times bigger must A’s sample be for A to beat B?
- Prove that \(\text{MSE}(\hat{\theta}) = \text{Bias}(\hat{\theta})^2 + \text{Var}(\hat{\theta})\), where \(\text{MSE}(\hat{\theta}) = E\big[(\hat{\theta} - \theta)^2\big]\). (Hint: write \(\hat{\theta} - \theta = \big(\hat{\theta} - E[\hat{\theta}]\big) + \big(E[\hat{\theta}] - \theta\big)\), square it, and take expectations.)
Question 3: Why R’s var() divides by \(n - 1\)
In week 3, you computed a variance by averaging the squared misses from the average: divide by \(n\). R’s var() divides by \(n - 1\) instead. This question shows why: dividing by \(n\) is a biased estimator of the population variance, \(\sigma^2\).
Use the counties population from Question 1.
Compute the population variance, \(\sigma^2\), dividing by \(N\). This is the estimand.
Draw 2,000 samples of 5 counties. For each sample, compute two estimators of \(\sigma^2\): the average squared miss from the sample average dividing by \(n\), and R’s
var(), which divides by \(n - 1\). What is the average of each estimator across the 2,000 samples? Which one is biased, and in which direction? By roughly what fraction is it off?Why too small? Do this part by hand. Say the true mean is \(\mu = 8\), and a sample of three counties has vote shares 2, 6, and 10.
- Compute the sample average, \(\bar{Y}\).
- Compute the sum of the squared misses from \(\bar{Y}\), and the sum of the squared misses from \(\mu\). Which is smaller?
- Check that the gap between the two sums equals \(n(\bar{Y} - \mu)^2\).
- In words: why do squared misses from \(\bar{Y}\) always add up to less than squared misses from \(\mu\)? (Hint: week 3 asked which guess makes the squared misses smallest.) Why does that make the divide-by-\(n\) estimator too small?
Repeat (b) with samples of 100 counties. How biased is the divide-by-\(n\) estimator now? Is it consistent?