开始使用免费开始使用

估计 AR 模型

您将估计在前一练习中生成的一条模拟序列的 AR(1) 参数 $\small \phi$。由于模拟序列的参数是已知的,这是在将方法应用到真实数据之前理解估计过程的好方式。

对于 simulated_data_1,其真实 \(\small \phi\) 为 0.9,您将打印出 \(\small \phi\) 的估计值。此外,您还将打印出拟合时间序列时产生的完整输出,以便了解 statsmodels 中还提供了哪些检验和汇总统计量。

本练习是课程的一部分

Python 中的时间序列分析

查看课程

练习说明

  • 从模块 statsmodels.tsa.arima.model 导入类 ARIMA
  • 使用模拟数据 simulated_data_1 创建一个名为 modARIMA 类实例,模型的 (p,d,q) 次数(此处为 AR(1))为 order=(1,0,0)
  • 使用 .fit() 方法拟合模型 mod,并将结果保存到名为 res 的结果对象中。
  • 使用 .summary() 方法打印完整结果摘要。
  • 仅使用 .params[1] 属性(不加括号)打印 \(\small \phi\) 的估计值。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the ARIMA module from statsmodels
from statsmodels.tsa.arima.model import ARIMA

# Fit an AR(1) model to the first simulated data
mod = ARIMA(___, order=___)
res = mod.___

# Print out summary information on the fit
print(res.___)

# Print out the estimate for phi
print("When the true phi=0.9, the estimate of phi is:")
print(res.___)
编辑并运行代码