Hello,
I am trying to do time-series forecasting (forecasting some volume by day).
My original data frame looks something like this:
# Libraries ###
library(ggplot2)
library(zoo) ## Use package zoo to convert to time series
library(forecast)
# Data ####
TimeModified = c('11/17/19','11/18/19','11/19/20')
n = c(717,17385, 15201)
ts_al1 <- data.frame(TimeModified, n)
# I convert the data frame to a time series object using:
z <- read.zoo(ts_al1, format = '%m/%d/%y')
# Generate an autoplot that works
a <- autoplot(z[,'n']) +
ggtitle("Manual Changes by Day")+
xlab('Day') +
ylab('Thousands')
a
# Now I start forecasting
# Say I want to use Naive Bayes and an average method####
meanf(z[,'n'], 2)
naive(z[,'n'],2) ## it works
# Problem is when I want to use the autolayer to show my forecasts graphically
autoplot(z[,'n']) +
autolayer(meanf(z[,'n'], h=3),
series="Mean", PI=FALSE) +
autolayer(naive(z[,'n'], h=3),
series="Naïve", PI=FALSE) +
ggtitle("Title") +
xlab("Day") + ylab("Volume") +
guides(colour=guide_legend(title="Forecast"))
## autolayer isn't working. I get the following errors:
## Error in forecast2plotdf(object, PI = PI, showgap = showgap) :
## Could not find forecast x axis
I appreciate any help.
Error in forecast2plotdf(object, PI = PI, showgap = showgap) :
Could not find forecast x axis