The goal of this supervision is to learn to use R to analyse the relationship between economic growth and various factors.

Google how to install R and RStudio. We will use these for several supervision sessions.

Using the data set called ‘USMacroG’, prepare plots to analyse the relationship between macroeconomic variables.

An example code is displayed below.

# Set CRAN mirror
options(repos = "https://cloud.r-project.org")

# Install and load the AER and tidyverse packages without displaying the output
install.packages(c("AER", "tidyverse")) 
library(AER)
library(tidyverse)


# Load the USMacroG data

data("USMacroG")

# Convert data to a data frame and calculate economic growth using the data

data <- as.data.frame(USMacroG) %>% mutate(growth = gdp / lag(gdp) - 1)

data = data %>% dplyr::select(growth, inflation, interest, unemp)
# Code to make a plot

plot(data$inflation, data$growth, xlab = "Inflation", ylab = "Growth", main = "Relationship between Inflation and Growth")

# Add a line of best fit
fit <- lm(growth ~ inflation, data = data) 
abline(fit, col = "red")

Adapt the code above to analyse the empirical relationship between interest rates, unemployment, inflation and GDP growth.

Save your plots and export them into a text document. Write down an analysis of each graph.

Bonus question: use the ‘GrowthSW’ data set to analyse the relationship between economic growth and the other variables in the data set. As well as using plots, use a regression incorporating all of the variables. This will allow you to see what variables are associated with growth after accounting for the other variables. (Hint: use the lm() function)

If you have extra time, you can start working through this introductory course to R: https://cran.r-project.org/doc/contrib/Torfs+Brauer-Short-R-Intro.pdf