Introduction to Econometrics: Exercises


4. Simple and log inflation. You are given the 2020 and 2021 cpi inflation rates: cpi_2020 and cpi_2021. Calculate the simple and log inflation rates using the formulas below:

\[ simple\_inflation_{t} = \frac{cpi_{t}}{cpi_{t-1}} - 1 \] \[ log\_inflation_{t} = log(\frac{cpi_{t}}{cpi_{t-1}}) \]

cpi_2020 <- 261.564 cpi_2021 <- 280.126 # Calculate the simple inflation rate. simple_inflation <- (___ / ___) - 1 # Calculate the log inflation rate. log_inflation <- ___(___ ___ ___) # Calculate the simple inflation rate. simple_inflation <- (cpi_2021 / cpi_2020) - 1 # Calculate the log inflation rate. log_inflation <- log(cpi_2021 / cpi_2020) test_error() test_object("simple_inflation", incorrect_msg="Did you take the ratio of the 2021 and 2020 CPI values?") test_object("log_inflation", incorrect_msg="Did you remember to use the `log()` function?") success_msg("Well done!")
Did you use the log() function to compute log inflation?

Previous Exercise Next Exercise