3. Log returns. You are given a dataframe, data
, which contains three columns: date
,
sp500
, and microsoft
. The sp500
column contains levels for the S&P 500 index and the microsoft
column
contains observations on Microsoft's stock price. All data is given at a monthly frequency.
Use the log()
and diff()
functions to compute the log returns for sp500
and
microsoft
. You can compute the log returns as follows: