[英]Using ggplot2 to plot ets() fitted model
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
. 现在,我需要使用
ggplot2
使该图看起来更好。 So, my specific question how to pass ETS model to ggplot2
to plot it? 那么,我的具体问题是如何将ETS模型传递给
ggplot2
进行绘制呢?
Use autoplot in stead of plot. 使用自动绘图代替绘图。 It is a function from the package ggplot2.
它是来自ggplot2包的函数。
autoplot(predict(ets(cmc), n.ahead = 5))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.