开始使用免费开始使用

AR(1) 与 MA(∞) 的等价性

为更好地理解 MA 模型与 AR 模型之间的关系,您将演示:在适当的参数下,AR(1) 模型等价于 MA(\(\small \infty\)) 模型。

您将用参数 \(\small 0.8, 0.8^2, 0.8^3, \ldots \) 模拟一个包含较多(30)滞后的 MA 模型,并展示它与 \(\small \phi=0.8\) 的 AR(1) 模型具有相同的自相关函数(ACF)。

注意:要将数字 x 提升到指数 n 的幂,请使用 x**n 的格式。

本练习是课程的一部分

Python 中的时间序列分析

查看课程

练习说明

  • 从 statsmodels 导入用于模拟数据和绘制 ACF 的模块。
  • 使用列表解析构建一组呈指数衰减的 MA 参数:\(\small 1, 0.8, 0.8^2, 0.8^3, \ldots\)
  • 模拟 5000 个 MA(30) 模型的观测值。
  • 绘制该模拟序列的 ACF。

交互式实操练习

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

# import the modules for simulating data and plotting the ACF
from statsmodels.tsa.arima_process import ArmaProcess
from statsmodels.graphics.tsaplots import plot_acf

# Build a list MA parameters
ma = [___ for i in range(30)]

# Simulate the MA(30) model
ar = np.array([1])
AR_object = ArmaProcess(ar, ___)
simulated_data = ___.generate_sample(nsample=5000)

# Plot the ACF
plot_acf(___, lags=30)
plt.show()
编辑并运行代码