Session Ready
Exercise

Convert a series to a lower frequency

Besides converting univariate time series to OHLC series, to.period() also lets you convert OHLC to lower regularized frequency - something like subsampling your data.

Depending on the chosen frequency, the index class of your data may be coerced to something more appropriate to the new data. For example, when using the shortcut function to.quarterly(), xts will convert your index to the yearqtr class to make periods more obvious.

We can override this behavior by using the indexAt argument. Specifically, using firstof would give you the time from the beginning of the period. In addition, you can change the base name of each column by supplying a string to the argument name.

For this exercise we'll introduce a new dataset, the edhec hedge fund index data from the PerformanceAnalytics package.

In this exercise you will use the Equity Market Neutral time series from the edhec data, which we've assigned to eq_mkt.

Instructions
100 XP
  • Convert eq_mkt to quarterly OHLC using the base to.period(). Call this mkt_quarterly.
  • Convert the original eq_mkt again, this time using to.quarterly() directly. Change the base name of each OHLC column to edhec_equity and change the index to "firstof". Call this mkt_quarterly2.