估计自回归(AR)模型
对于给定的时间序列 x,我们可以使用 arima() 命令并将 order 设为 c(1, 0, 0) 来拟合自回归(AR)模型。作为参考,AR 模型等同于 ARIMA(1, 0, 0) 模型。
在本练习中,您将通过在模拟时间序列 x 和 AirPassengers 数据上练习使用 arima() 命令,来探索 AR 模型的更多性质。该命令可用于识别模型的估计斜率(ar1)、均值(intercept)和创新方差(sigma^2)。
x 和 AirPassengers 数据都已预加载到您的环境中。右侧图中显示了时间序列 x。
本练习是课程的一部分
R 中的时间序列分析
练习说明
- 使用
arima()将 AR 模型拟合到序列x。请仔细查看该命令的输出。 - 您在上一步命令得到的斜率(
ar1)、均值(intercept)和创新方差(sigma^2)的估计值分别是多少?请将它们输入到您的 R 工作区。 - 现在,将 AR 模型拟合到
AirPassengers,并将结果保存为AR。使用print()显示已拟合的模型AR。 - 最后,使用提供的命令绘制
AirPassengers,计算拟合值,并将其添加到图中。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fit the AR model to x
arima(___, order = ___)
# Copy and paste the slope (ar1) estimate
# Copy and paste the slope mean (intercept) estimate
# Copy and paste the innovation variance (sigma^2) estimate
# Fit the AR model to AirPassengers
AR <-
print(AR)
# Run the following commands to plot the series and fitted values
ts.plot(AirPassengers)
AR_fitted <- AirPassengers - residuals(AR)
points(AR_fitted, type = "l", col = 2, lty = 2)