You can assume that numpy, matplotlib, scipy and pandas-datareader are installed on the machine of the person
Question:
You can assume that numpy, matplotlib, scipy and pandas-datareader are installed on the machine of the person who will run and mark your notebook. There is no need to force an install with the ! command. For textual answers please use a markdown cell.
1. You will first download the world GDP data from the World Bank using pandas_datareader (which we used in lab 2). The following code will download and plot the entire world GDP time series. Do NOT make any local copies of your data
from pandas_datareader import wb import matplotlib.pyplot as plt import numpy as np gdp_data = wb. download ( indicator='NY.GDP.MKTP.CD' , country='WLD' , s t a r t=' 1960 ' , end=' 2021 ' ) time = np.arange(1960, 2022) gdp = gdp_data.iloc[:, 0].astype(float).to_numpy() # Data is returned in inverse chronological order, so reverse order gdp = np.flip(gdp) #Plot World GDP against time plt.plot (time , gdp , label='US GDP') plt.legend() plt.show()
(you can ignore the warning about the code `WLD'). You will try to estimate the long-term annual growth rate of the world using a regression.
QUESTIONS
If the growth rate was a constant r, then the world's GDP would grow as: GDPk = GDP0(1 + r) k where k is the number of years since 1960 and GDP0 is the world's GDP in 1960. This is clearly not a linear relationship between time (k, in years) and GDP. However, we can get a linear relationship by applying a simple transformation f(−) on both side of the equation. What is this transformation? (Hint: we used this transformation in the context of MLE, it turns products into sums.)
1. Apply this transformation f(−) to the GDP data, and perform a regression against the time variable. On the same plot, display your regression line, a scatter-plot of the (transformed) data points, and your R2 value.
2. Compute the residuals of your regression (i.e. the difference between the model and the observations), and print their mean and their standard deviation σˆ. Perform a KS-test to determine whether we can reject the null hypothesis that the residuals are sampled from a normal distribution with mean 0 and standard deviation σˆ. Take α = 99%.
3.You will now apply the inverse of the transformation f(−) to your linear model in order to get a non-linear model for the GDP. On the same plot, display your (non-linear) model and a scatter-plot of the (original) data points.
4.What is the relationship between the slope of the regression and the long-term growth rate of the world GDP? Compute the long-term growth rate of the world GDP.
5.What do you observe since approximately 2015?