1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Portfolio Analysis in R

Exercise

Subperiod performance analysis and the function window

In the previous exercise, you computed the performance measure on each possible sample of a fixed size by rolling through time. Often investors are interested in the performance of a specific subwindow. You can create subsets of a time series in R using the function window(). The first argument is the return series that needs subsetting. The second argument is the starting date of the subset in the form "YYYY-MM-DD", and the third argument is the ending date in the same format.

In this exercise, you will be working with the daily S&P 500 returns, which is available as the object sp500_returns.

Instructions

100 XP
  • Fill in the missing arguments to the object sp500_2008 so that you have subsetted the entire year of 2008.
  • Define the object sp500_2014 as the S&P 500 portfolio returns for 2014.
  • Some plotting settings are added in the R console. Leave these as they are!
  • Plot histogram of returns in 2008 using the function chart.Histogram(). Set the argument methods = c("add.density", "add.normal") to visualize the non-parametric estimate of the density and the density under an assumed normal distribution.
  • Plot the same histogram, but for 2014.