开始使用免费开始使用

估计简单移动平均模型

在您已经模拟了一些 MA 模型并计算了这些模型的 ACF 之后,下一步是使用 arima() 命令把简单移动平均(MA)模型拟合到实际数据上。对于给定的时间序列 x,我们可以使用 arima(..., order = c(0, 0, 1)) 来拟合简单移动平均(MA)模型。作为参考,MA 模型就是一个 ARIMA(0, 0, 1) 模型。

在本练习中,您将练习使用一个预加载的时间序列(x,见右侧图)以及在前面章节使用过的 Nile 数据集。

本练习是课程的一部分

R 中的时间序列分析

查看课程

练习说明

  • 使用 arima() 将 MA 模型拟合到序列 x 上。
  • arima() 的输出中,记录斜率(ma1)、均值(intercept)和创新方差(sigma^2)的估计值。将这些数值粘贴到您的工作区中。
  • 以类似方式调用 arima(),将 MA 模型拟合到 Nile 数据。将结果保存为 MA,并使用 print() 显示输出。
  • 最后,使用预先写好的命令绘制 Nile 数据以及您拟合得到的 MA 值。

交互式实操练习

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

# Fit the MA model to x
arima(___, order = ___)

# Paste the slope (ma1) estimate below


# Paste the slope mean (intercept) estimate below


# Paste the innovation variance (sigma^2) estimate below


# Fit the MA model to Nile
MA <- arima(___, order = ___)
print(MA)

# Plot Nile and MA_fit 
ts.plot(Nile)
MA_fit <- Nile - resid(MA)
points(MA_fit, type = "l", col = 2, lty = 2)
编辑并运行代码