取差分
在本练习中,您将为一个城市的人口时间序列做建模前的准备。如果能够预测城市的人口增长率,就可以提前规划和建设所需的基础设施,从而更好地配置公共支出。本题中的时间序列是虚构的,但非常适合练习。
您将先通过目测和增广 Dickey-Fuller 检验来判断平稳性,并通过取差分让数据集达到平稳。
时间序列的 DataFrame 已以 city 名称为您加载,adfuller() 函数也已导入。
本练习是课程的一部分
Python 中的 ARIMA 模型
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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:', ____)