R 预测 stl 时的错误信息 no applicable method

问题描述 投票:0回答:0

此代码运行良好。

library(fpp2)
fit %>% seasadj() %>% naive() %>%
  autoplot() +
  guides(colour = guide_legend(title = "Forecast")) +
  labs(level = "Level") +
  ylab("New orders index") +
  ggtitle("Naive forecasts of seasonally adjusted data")

虽然我没有传说。但是这段代码给我一个错误

fit %>% forecast(method = "naive") %>%
  autoplot() +
  ylab("New orders index") +
  ggtitle("Naive forecasts of seasonally adjusted data")
Error in UseMethod("forecast") :
no applicable method for 'forecast' applied to an object of class "stl"

我得到与例如相同的结果

myfit <- forecast(fit, method = "naive")
Error in UseMethod("forecast") : 
  no applicable method for 'forecast' applied to an object of class "stl"

任何帮助将不胜感激。

r
© www.soinside.com 2019 - 2024. All rights reserved.