Exercise

Fitting t distribution to data

A Student t distribution is generally a much better fit to daily, weekly, and monthly returns than a normal distribution.

You can create one by using the fit.st() function in the QRM package. The resulting fitted model has a parameter estimates component par.ests which can be assigned to a list tpars in order to store its values of nu, mu, and sigma for later use:

> tfit <- fit.st(ftse)
> tpars <- tfit$par.ests
> tpars
          nu           mu        sigma
2.949514e+00 4.429863e-05 1.216422e-02

In this exercise, you will fit a Student t distribution to the daily log-returns of the Dow Jones index from 2008-2011 contained in djx. Then, you will plot a histogram of the data and superimpose a red line to the plot showing the fitted t density. The djx data and QRM package have been loaded for you.

Instructions

100 XP
  • Use fit.st() to fit a Student t distribution to the data in djx and assign the results to tfit.
  • Assign the par.ests component of the fitted model to tpars and the elements of tpars to nu, mu, and sigma, respectively.
  • Fill in hist() to plot a histogram of djx.
  • Fill in dt() to compute the fitted t density at the values djx and assign to yvals. Refer to the video for this equation.
  • Fill in lines() to add a red line to the histogram of djx showing the fitted t density.