bus <- read_csv("https://raw.githubusercontent.com/cobriant/dplyrmurdermystery/master/bus.csv") %>%
group_by(bus) %>%
mutate(month = row_number()) %>%
ungroup()Unit 3 Practice Test
The Unit 3 test and retake will be about 50% similar to this practice test: make sure to review Rust (part 1) and Rust (part 2) in their entirety to prepare.
Question 1: The Economic Model
John Rust models engine replacement as a dynamic decision problem.
State: \(s = \mathrm{mileage bucket}\)
Actions: keep the engine or replace it
The per-period payoff functions are:
\[v_{\mathrm{keep}} = -\theta_1 + 0.001 \cdot s + \beta EV_{\mathrm{keep}}(s)\] \[v_{\mathrm{replace}} = -\theta_2 + \beta EV_{\mathrm{replace}}(s)\]
What does a larger \(\theta_1\) imply about the best policy to minimize long-run costs?
What does a larger \(\theta_2\) imply about the best policy to minimize long-run costs?
Why is it important that this model dynamic rather than static?
Question 2: Exploring the Data
We observe each bus’s mileage bucket each month.
Plot mileage over time for bus “GMC_A5308_75_5302”.
In the time series plot, the mileage sometimes drops sharply. What event does this represent?
Question 3: Transition Matrices
Rust assumes mileage evolves stochastically when the engine is kept.
\[(p_0, p_1, p_2) = (.3489, .6394, .0117)\]
What does the matrix \(T_{\mathrm{keep}}\) look like and why?
What does the matrix \(T_{\mathrm{replace}}\) look like and why?
Fill in the transition matrix for replace:
t_replace <- matrix(rep(0, 90*90), nrow = 90)
for(i in 1:90) {
t_replace[i, 1] <- ___
t_replace[i, 2] <- ___
t_replace[i, 3] <- ___
}Question 4: Value Iteration
Given parameters \(\theta = (\theta_1, \theta_2)\), we solve the dynamic programming problem using value iteration.
- Fill in the continuation values in the value iteration routine.
value_iteration <- function(theta, tol = 0.01) {
V <- rep(0, S)
V_old <- rep(1, S)
while (max(abs(V - V_old)) > tol) {
V_old <- V
EV_keep <- as.vector(___ %*% V_old)
EV_replace <- as.vector(___ %*% V_old)
v_keep <- -theta[1] * 0.001 * (1:S) + beta * ___
v_replace <- -theta[2] + beta * ___
V <- logsumexp(v_keep, v_replace)
}
list(v_keep = v_keep, v_replace = v_replace)
}Question 5: Choice Probabilities
With extreme value preference shocks, the model implies logit choice probabilities:
\[P(\mathrm{keep}) = \frac{\exp(v_{\mathrm{keep}})}{\exp(v_{\mathrm{keep}}) + \exp(v_{\mathrm{replace}})}\]
If maintenance costs \(\theta_1\) increase, what happens to the probability of keeping the engine at high mileage levels? Explain.
If replacement costs \(\theta_2\) increase, what happens to the probability of keeping the engine at high mileage levels? Explain.
Will logit choice probabilities ever exceed 1? Explain.
Question 6: Conceptual Questions
Rust (1987) is a seminal paper in the dynamic discrete choice literature in Econometrics. For an economist, why are dynamic discrete choice models useful? Compare this to how an inverse reinforcement learning model is useful to a machine learning practitioner.
What’s the difference between
t_keep,t_replace, andp_lrfrom the assignment on counterfactuals?In a couple of sentences, summarize the nested fixed point algorithm.