Get startedGet started for free

Compare simple and continuously compounded returns

You would like to compare the simple and the continuously compounded returns. In the next exercise, you will do that by generating two graphs. In this exercise, you will just have a quick look at the data. It would be nice to have the simple and continuously compounded return next to each other in a matrix, with \(n\) rows and two columns. You can use the cbind() function to paste the two vectors that contain both types of returns next to each other in a matrix.

This exercise is part of the course

Intro to Computational Finance with R

View Course

Exercise instructions

Use the cbind() and head() functions to display the simple and continuously compounded returns next to each other for the first time periods. What do you notice?

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# The sbux_df data frame is already loaded in your work space
sbux_prices_df <- sbux_df[, "Adj.Close", drop = FALSE]

# Denote n the number of time periods:
n <- nrow(sbux_prices_df)
sbux_ret <- (sbux_prices_df[2:n, 1] - sbux_prices_df[1:(n - 1), 1]) / sbux_prices_df[1:(n - 1), 1]

# Compute continuously compounded 1-month returns
sbux_ccret <- log(sbux_prices_df[2:n,1]) - log(sbux_prices_df[1:(n - 1),1])
names(sbux_ccret) <- sbux_df[2:n,1]
head(sbux_ccret)

# Compare the simple and cc returns
Edit and Run Code