I'm trying to do exponential smoothing to a simple time series data set and plot the fitted model plus the foretasted model, here is the code:
cmc
[1] 100 104 108 111 120 120 127 130 142 138 170 177 180 200 230 235 247
[18] 260 263 270 330 350 400 450 500
plot(predict(ets(cmc), n.ahead = 5))
Now, I need the plot to look much better using ggplot2
. So, my specific question how to pass ETS model to ggplot2
to plot it?
Use autoplot in stead of plot. It is a function from the package ggplot2.
autoplot(predict(ets(cmc), n.ahead = 5))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.