Ошибка ввода с использованием autoplot и ggplot2: неверный ввод: date_trans работает только с объектами класса Date - PullRequest
0 голосов
/ 10 июля 2020
    library(quantmod)
GDP.growth <- ts(data = getSymbols('A191RL1Q225SBEA', src = 'FRED', auto.assign = F), frequency = 4, start = c(1947,2))

library(ggplot2)
library(forecast)

fit.1 <- arima(ts(GDP.growth[1:259], frequency = 4, start = c(1947,2)), order = c(1,0,0))
summary(fit.1)

fit.2 <- arima(ts(GDP.growth[1:259], frequency = 4, start = c(1947,2)), order = c(3,0,2))
summary(fit.2)

fc.1 <- forecast(ts(GDP.growth[1:259], frequency = 4, start = c(1947,2)), h = 20, model = fit.1)

fc.2 <- forecast (ts(GDP.growth[1:259], frequency = 4, start = c(1947,2)), h = 20, model = fit.2)

autoplot(GDP.growth)+autolayer(fitted(fc.1), color="blue")+autolayer(fc.1, color=alpha("pink", 1/3))

autoplot(GDP.growth)+autolayer(fitted(fc.2), color="blue")+autolayer(fc.2, color=alpha("pink", 1/3))

Я получаю следующее сообщение:

Invalid input: date_trans works with objects of class Date only

Когда я рисую только автоплот, он работает. Похоже, проблема кроется после "+". Может ли кто-нибудь помочь мне с этой проблемой?

...