估计 MA 模型
您将估计先前练习中生成的一条模拟序列的 MA(1) 参数 $\small \theta$。由于模拟序列的参数是已知的,这有助于在处理真实数据之前先理解估计流程。
对于 simulated_data_1(其真实 \(\small \theta\) 为 -0.9),请打印出 \(\small \theta\) 的估计值。此外,在拟合时间序列时还请打印出完整的输出结果,以便了解 statsmodels 中还提供了哪些检验和汇总统计量。
本练习是课程的一部分
Python 中的时间序列分析
练习说明
- 从模块
statsmodels.tsa.arima.model导入类ARIMA。 - 使用模拟数据
simulated_data_1和模型的 (p,d,q) 次数(此处为 MA(1)),创建名为mod的ARIMA类实例,order=(0,0,1)。 - 使用
.fit()方法拟合模型mod,并将结果保存为名为res的结果对象。 - 使用
.summary()方法打印完整的结果摘要。 - 仅打印 theta 参数的估计值,使用属性
.params[1]。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import the ARIMA module from statsmodels
from statsmodels.tsa.arima.model import ARIMA
# Fit an MA(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 the constant and for theta
print("When the true theta=-0.9, the estimate of theta is:")
print(res.___)