Introduction to Econometrics: Exercises


5. Real log returns. You are given a data frame, data, which contains the variables, log_real_returns and log_inflation_rate for the period between 2011 and 2021.

The real log return is computed as follows:

\[ real\_log\_return_{t} = log\_return_{t} - log\_inflation_{t}\]

dates <- c("2012-01-01","2013-01-01","2014-01-01","2015-01-01","2016-01-01", "2017-01-01","2018-01-01","2019-01-01","2020-01-01","2021-01-01") log_return <- c(-0.031904211,0.028994207,-0.264031081,-0.15822276,0.160653519, 0.051089674,-0.126810388,0.13166768,-0.101928956,0.192571489) log_inflation <- c(0.007574986,0.006520971,0.002827248,0.002765125,0.008816409, 0.009153037,0.008239028,0.009713099,0.005515779,0.02977545) data <- data.frame( dates <- dates, log_return = log_return, log_inflation = log_inflation ) # Calculate the real log return. real_log_return <- data$___ - ___ # Add real log return to data frame. ___$real_log_return <- ___ # Plot histogram of real log returns. ___(data$real_log_return) # Calculate the real log return. real_log_return <- data$log_return - data$log_inflation # Add real log return to data frame. data$real_log_return <- real_log_return # Plot histogram of real log returns. hist(data$real_log_return) test_error() test_object("real_log_return", incorrect_msg="Did you the correct variables to compute `real_log_return`?") test_function("hist", incorrect_msg="Recall that you can create a histogram with the `hist()` function.") success_msg("Well done! Notice that you can compute the real log return exactly from the log return and log inflation.")
Did you the correct variables to compute real_log_return?

Previous Exercise Next Exercise