如何使用情节完成预测线?

时间:2017-12-31 18:32:03

标签: r data-visualization forecasting

我一直在研究R中的一个预测数字的脚本。

public function getPackage($type)
{
    $sale = Tour::where('id_package', $type)->with(['location', 'package'])->get();
    return view('page.package', compact('sale'));
}

此输出提供此

plot

不知何故,预测的行与实际值没有关联。

问题:如何将线路从上次已知值链接到第一个预测值?

编辑01/01:以下是CSV所在的link以重现案例。

1 个答案:

答案 0 :(得分:0)

您需要将实时系列添加到预测的系列中,如下面的代码

pred_mod<-pred
ts_real<-pred$x
pred_mod$x<-ts(c(ts_real,pred$mean),frequency=12,start=c(2015,1))
plot(pred_mod)

here the result