Applied Exercises

1. Estimate a logit regression using MLE

In this exercise you will estimate a logit regression model using maximum likelihood.

Recall the log likelihood of the logit model from Section 1:

L(β)=i=1N  yiln(exp(xiβ)1+exp(xiβ))+(1yi)ln(11+exp(xiβ))\mathcal{L}(\beta) = \sum^N_{i=1} \; y_i \ln\left( \frac{exp(x_i \beta)}{1+exp(x_i \beta)} \right) + (1-y_i) \ln\left( \frac{1}{1+exp(x_i \beta)} \right)

Using the dataset provided in Section 1, write a script that estimates the unknown parameter β\beta using

  1. fminunc

  2. fminsearch

  3. fminbnd

2. Estimate an AR(1) regression using MLE

In this exercise you will estimate an AR(1) regression using Maximum Likelihood.

This task consists of two parts. In the first part you will simulate data from a stationary AR(1). In the second part you will use this data to estimate the AR(1) model by MLE and verify that you correctly estimated ϕ\phi and σ2\sigma^2.

  1. Simulate data from a stationary AR(1) model building on the code example we covered in Part A of unit 4. Set T=500T=500 and use y0=0y_0=0 and use 200 burn-in periods. Use the same parameter values that we used in the example. After you have simulated the data, export the vector containing the yy values into a .mat file using the save command.

  2. Create a new script and load the .mat file you just generated. Write function file for the target function which calculates the likelihood given parameter values for ϕ\phi and σ\sigma. Then, create a new script and use fminunc to estimate ϕ\phi and σ2\sigma^2 from the data on yy you just imported.

Note: Remember that you have to choose sensible starting values for the optimisation algorithm. Make sure these starting values are different from the true parameter values you used to generate the data.

Theory

Consider the following stable AR(1) model

yt=ϕ  yt1+ϵtϵtiid  N(0,σ2),ϕ<1y_t = \phi \; y_{t-1} + \epsilon_t \hspace{20pt} \epsilon_t \sim iid \; N(0,\sigma^2), \hspace{20pt} |\phi|<1

We would like to estimate the unknown parameters ϕ,σ2\phi, \sigma^2 by maximum likelihood. Therefore we would like to find the values of ϕ\phi and σ2\sigma^2 which maximize the following log-likelihood.

3. Solving an optimal consumption problem

In this exercise you will solve an optimal consumption problem using MATLABs numerical solvers.

Consider a consumer who solves the following consumption (CC) vs. leisure (LL) problem

maxC,L  ACα(1L)βmax_{C,L} \; AC^{\alpha}(1-L)^{\beta}

subject to the budget constraint C=wL C=wL where ww is the wage.

Write a Matlab program that solves this problem for given parameter values of AA, α\alpha, β\beta, and ww. In particular

  • Start by reducing the problem to a one-dimensional problem in either CC or LL.

  • First solve the one-dimensional problem using the fzero function.

  • Then solve the one-dimensional problem using the fminunc function.

Last updated