Aggregating log-returns
1. Aggregating log-returns
2. Aggregating log-returns
I remarked before that it is easy to aggregate shorter interval log-returns like daily returns to obtain longer-interval returns like weekly or monthly returns. Effectively you just add them up! Why would you want to do this? Well, by aggregating returns, you can study the risks over longer time horizons, such as a month, a quarter, or a year. There is some simple mathematics behind the aggregation of log-returns. Let's assume that the series (X_t) are daily log-returns calculated from daily risk-factor values (Z_t). Let's assume further that (Z_t) is a price series for some asset that is traded on weekdays. To get the log-return for a whole trading week starting on day t (effectively the previous Friday evening price before markets open on the Monday morning) and ending on day t+5 (Friday evening again), you would calculate the difference log(Z_{t+5}) - log(Z_t). It can be shown that this is just the sum of the log-returns for each of the trading days. And a similar calculation works for any aggregation period.3. Aggregating log-returns in R
To do this in R, you can use a set of functions in the xts package with names like apply weekly and apply monthly. If the object sp500x is an xts object contains daily log-returns, you obtain weekly returns by applying the sum function within the apply weekly function. Note how the returns now have date stamps that are seven days apart. Similarly, to get monthly returns, you apply the sum function within the apply monthly function. Now the date stamps are the last days of each calendar month. Note that if you have a multivariate time series containing, for example, multiple stock prices, you have to apply the function colSums() instead of sum(). Look out for an example of that at the end of the next exercise.4. Let's practice!
So now it is time to practice aggregating log-return series.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.