Basic Math & Time Value of Money: Exercises


4. Cumulative simple returns. In the previous exercise, you computed the simple returns at a monthly frequency for the S&P500 index. We stored this as a vector named sp500_simple_returns, which has been defined for you in this exercise.

You now want to compute cumulative simple returns, starting at period 1 and extending to each period, t, in the same. Recall that you can compute them between periods 0 and t using the following expression:

cumulative_return1t=(1+R1)(1+R2)(1+Rt)1

In R, the cumprod() function can be used to compute the cumulative product for every observation in the sample.



Previous Exercise Next Exercise