Exercise

# Overlapping returns

When you aggregate series by summing daily log-returns into longer intervals, you analyze a smaller amount of observations. To preserve the quantity of data, you can calculate **overlapping returns** with the `rollapplyr()`

function; this also creates strong correlations between observations.

There are 5 trading days in the average calendar week. By computing the 5-day **moving sums** of the log-returns of daily index data, you obtain approximate overlapping weekly returns ending on each calendar week. Similarly, calculating 21-day moving sums gives approximate overlapping monthly returns, and calculating 63-day moving sums gives approximate overlapping quarterly returns.

Let's look at an example with the Dow Jones daily return data in `djx`

. Because 5 values are used to calculate each moving sum, the first 4 values in the result are `NA`

. In this instance, we will use indexing to remove them:

```
> djx5 <- rollapplyr(djx, width = 5, FUN = sum)
> head(djx5)
^DJI
2008-01-03 NA
2008-01-04 NA
2008-01-07 NA
2008-01-08 NA
2008-01-09 -0.02394677
2008-01-10 -0.01571869
> djx5 <- djx5[-(1:4)]
```

In this exercise, you will calculate moving sums of different intervals from `djx`

, which is loaded in your workspace. You will then find the skewness and kurtosis of the resulting data and conduct the Jarque-Bera test just as you have in previous exercises. Do the overlapping returns appear more normal?

Instructions

**100 XP**

- Calculate a 21-day moving sum of the log-returns in
`djx`

, remove the first 20 values, and assign to`djx21`

. - Calculate a 63-day moving sum of the log-returns in
`djx`

, remove the first 62 values, and assign to`djx63`

- Use
`merge()`

and`all = FALSE`

to merge`djx`

,`djx21`

, and`djx63`

in that order, then assign to`djx2`

. Plot it with`plot.zoo()`

. - Use
`apply()`

and the appropriate functions to compute the skewness and kurtosis for each of the series in`djx2`

. - Use
`apply()`

and the appropriate function to conduct the Jarque-Bera test on each of the series in`djx2`

.