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

Connected

Exercise

Split-sample evaluation

In chapter 2, you used the function window() to subset your returns for graphical purposes. In this exercise, you will use the window() to create two samples: an estimation sample and an evaluation sample. This exercise will illustrate how portfolio weights can differ when changing the estimation window.

To remind you, the function window() has argument of x, start, and end. Where start and end are in the format "YYYY-MM-DD".

The object returns is loaded in your workspace.

Instructions

100 XP
  • Create the sample returns_estim by subsetting returns, where the sample begins on January 1st, 1991, and ends on December 31st, 2003.
  • Create the sample returns_eval by subsetting returns, where the sample begins on the first day of 2004 and ends on the last day of 2015.
  • Create a vector of maximum weights equal to 10%, with a length as the number of columns there are in returns called max_weights.
  • Create a portfolio with the estimation sample called pf_estim, where the maximum weight (reshigh) is set to max_weights.
  • Create a portfolio with the evaluation sample called pf_eval, where the maximum weight (reshigh) is set to max_weights.
  • Create a scatter plot of the evaluation portfolio weights versus the estimation portfolio weights (note that you can use $pw). If portfolio weights are identical, they should be on the 45-degree line.