更新时间:2023-02-18 12:08:51
由于您使用默认配置调用了forecast()
,因此预测为一条直线.这将调用ets()
(查看forecast(tsValue,h=5)$method
以查看用于预测的方法),并将模型指定为"ZZZ". ets()
然后尝试找到***模型并基于"ANN":附加误差,无趋势,无季节性(请参见?ets
),因此模型中没有任何内容会导致预测偏离一条直线.添加更多数据并通过趋势调用ets()
来查看趋势预测:
The forecast is a flat line since you invoked forecast()
with its default configuration. This invokes ets()
(look at forecast(tsValue,h=5)$method
to see which method was used for forecasting), with a model specified as "ZZZ". ets()
then tries to find the best model and settles on "ANN": additive error, no trend, no seasonality (see ?ets
), so there is nothing in the model which should cause the forecast to deviate from a flat line. Add some more data and call ets()
with a trend to see a trend forecast:
YrTimeSeries <- c(40,60,67,80,87,100,200,300,400)
tsValue<-ts(YrTimeSeries,frequency=1,start=2006)
forecast(tsValue,h=5,model="AAN")
95%的预测间隔为您提供了一个间隔,其中95%的未来观察结果位于该范围内,假设您的模型已正确指定.
The 95% predictive interval gives you an interval in which 95% of future observations will lie, assuming that your model is correctly specified.
Vids评论说,他希望预测值在0到100之间(以百分比为单位).在这种情况下,我首先将输入数据转换为logits(http://en.wikipedia.org/wiki/Logit),然后在其中添加一些数据,以便获得自动趋势:
Vids comments that he would like the forecast to be between 0 and 100 as a percentage. In this case, I would first transform the input data to logits (http://en.wikipedia.org/wiki/Logit), where I added some data so we get an automatic trend:
YrTimeSeries <- c(10,20,30,40,60,67,80,87)
YrTimeSeries.logit <- log((YrTimeSeries/100)/(1-YrTimeSeries/100))
tsValue<-ts(YrTimeSeries.logit,frequency=1,start=2006)
预测后,我们对平均预测和预测间隔限制进行了反变换:
After forecasting, we backtransform the mean forecast and prediction interval limits:
100*(1/(1+exp(-(forecast(tsValue,h=5)$mean))))
100*(1/(1+exp(-(forecast(tsValue,h=5)$upper))))
100*(1/(1+exp(-(forecast(tsValue,h=5)$lower))))