Assignment 4
Estimating a Finite Mixture Model with EM
Part 1
Take the model from Assignment 3 and introduce some time-invariant unobserved heterogeneity by allowing the cost parameter \(\kappa\) to depend on an individual’s type \(k\in\{1,2,...,K\}\).
Write code to simulate panel data \(\{d_{n,t},w_{n,t}\}_{n=1,t=1}^{N,T}\) from a model with \(K=2\), where \(d_{n,t}\) is a dummy variable indicating whether agent \(n\) worked in period \(t\). You can choose your own parameters for \((\kappa_{1},\kappa_{2})\). You can assume mixing probabilities \(P[k=1]=P[k=2]=0.5\).
To simplify estimating initial conditions, you can assume that everyone in the data begins with \(d_{0}=0\).
Part 2
Now consider the problem of estimating the following set of probabilities:
\[ \mathbf{P} = \{P[k], P[j=1|d_{t-1},k,w] \}_{k\in\{1,2\},\ w\in\{L,H\}, d_{t-1}\in\{0,1\}} \]
Write code to estimate these probabilities using the Expectation-Maximization algorithm. You can, as before, assume that \(\pi\) and (\(w_{L},w_{H})\) are known.
You may find the following formulae helpful. Given a guess of \(\mathbf{P}^{m}\), let \(q_{nk}\) be the posterior probability that person \(n\) is of type \(k\). It can be written as:
\[ q_{nk} = \frac{P^{m}[k]\prod_{t=1}^{T}P^{m}[j=1|d_{n,t-1},k,w_{t}]^{d_{n,t}}(1 - P^{m}[j=1|d_{n,t-1},k,w_{t})^{1 - d_{n,t}}}{\sum_{k'}P^{m}[k']\prod_{t=1}^{T}P^{m}[j=1|d_{n,t-1},k',w_{t}]^{d_{n,t}}(1 - P^{m}[j=1|d_{n,t-1},k',w_{t})^{1 - d_{n,t}}} \]
where \(d_{n,t}=1\) if person \(n\) works in period \(t\).
With these posteriors in hand, the m-step can be calculated using weighted frequency estimators. For example:
\[ P^{m+1}[j=1|d_{-1}=1,k,w_{H}] = \frac{\sum_{n,t}d_{n,t-1}d_{n,t}\mathbf{1}\{w_{n,t}=w_{H}\}q_{nk}}{\sum_{n,t}d_{n,t-1}\mathbf{1}\{w_{n,t}=w_{H}\}q_{nk}}.\]
Part 3
Demonstrate the performance of your estimation algorithm by running a monte-carlo simulation.