【问题标题】:Using ggplot2 to plot ets() fitted model使用 ggplot2 绘制 ets() 拟合模型
【发布时间】:2017-06-22 14:16:07
【问题描述】:

我正在尝试对一个简单的时间序列数据集进行指数平滑,并绘制拟合模型和预测模型,这里是代码:

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))

现在,我需要使用ggplot2 使情节看起来更好。那么,我的具体问题是如何将 ETS 模型传递给ggplot2 来绘制它?

【问题讨论】:

    标签: r ggplot2 prediction exponential


    【解决方案1】:

    使用自动绘图代替绘图。它是 ggplot2 包中的一个函数。

    autoplot(predict(ets(cmc), n.ahead = 5))
    

    【讨论】:

    • 非常感谢 Eddyvonb。现在我有了基础绘图层,我可以使用 ggplot 各种选项进行自定义。干杯,是。
    • @isibrahim 把我的回答标记为有用,那么很明显你的问题得到了回答
    猜你喜欢
    • 1970-01-01
    • 2019-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    相关资源
    最近更新 更多