首页 > 解决方案 > “x”是一个列表,但没有组件“x”和“y”(预测)

问题描述

我正在尝试计算和绘制该系列未来 2 年的下一个预测。

这是我的代码

library(astsa)
data(jj)
Amodel=arima(log(jj),order=c(0,1,1),seasonal=list(order=c(0,1,1),period=4))
plot(Amodel,n1=c(1978,1),n.ahead=8,pch=19,ylab='Log(Earnings)')

但 Rstudio 表明Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'

解决办法是什么?

标签: rtime-series

解决方案


arima返回包含模型输出的列表。您可以使用操作符(即)查看列表的这些元素names()并访问模型的各个部分。您将需要决定要绘制模型的哪一部分,因为该函数将期望与提供的输入不同的输入。此外,并且不是参数。$Amodel$armaplot()ariman.aheadn1plot()

library(astsa)

data(jj)

Amodel <- arima(log(jj),order=c(0,1,1),seasonal=list(order=c(0,1,1),period=4))

names(Amodel) #see parts of the model

plot(Amodel$arma,pch=19,ylab='Log(Earnings)') #plot example - change as you wish

推荐阅读