To log continuous compund returns of a time series in R, you can use the log_returns()
function from the quantmod
package. Here's an example:
main.r367 chars15 lines
This code will download the daily prices for IBM stock and then calculate the continuous compound returns by taking the logarithm of the ratio of each day's closing price to the previous day's closing price. The resulting time series will represent the daily continuous compound returns for IBM stock. The plot()
function is used to create a visual representation of the continuous compound returns.
gistlibby LogSnag