Augmented Dicky-Fuller
In this exercise you will run the augmented Dicky-Fuller test on the earthquakes time series to test for stationarity. You plotted this time series in the last exercise. It looked like it could be stationary, but earthquakes are very damaging. If you want to make predictions about them you better be sure.
Remember that if it were not stationary this would mean that the number of earthquakes per year has a trend and is changing. This would be terrible news if it is trending upwards, as it means more damage. It would also be terrible news if it were trending downwards, it might suggest the core of our planet is changing and this could have lots of knock on effects for us!
The earthquakes DataFrame has been loaded in for you as earthquake
.
This exercise is part of the course
ARIMA Models in Python
Exercise instructions
- Import the augmented Dicky-Fuller function
adfuller()
fromstatsmodels
. - Run the
adfuller()
function on the'earthquakes_per_year'
column of theearthquake
DataFrame and assign the result toresult
. - Print the test statistic, the p-value and the critical values.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import augmented dicky-fuller test function
from statsmodels.tsa.stattools import ____
# Run test
result = ____
# Print test statistic
print(____)
# Print p-value
print(____)
# Print critical values
print(____)