Taking the difference
In this exercise, you will to prepare a time series of the population of a city for modeling. If you could predict the growth rate of a city then it would be possible to plan and build the infrastructure that the city will need later, thus future-proofing public spending. In this case the time series is fictitious but its perfect to practice on.
You will test for stationarity by eye and use the Augmented Dicky-Fuller test, and take the difference to make the dataset stationary.
The DataFrame of the time series has been loaded in for you as city
and the adfuller()
function has been imported.
Cet exercice fait partie du cours
ARIMA Models in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Run the ADF test on the time series
result = ____(____)
# Plot the time series
fig, ax = plt.subplots()
city.plot(ax=ax)
plt.show()
# Print the test statistic and the p-value
print('ADF Statistic:', ____)
print('p-value:', ____)