问题
I have few questions regarding the forecast time series model in R.
The forecast values which i got for this is::
Want to take these values: 40,60,67,80,87
as the percentage values.
So, How to consider Y-axis of the plot in percenatge
YrTimeSeries <- c(40,60,67,80,87);
tsValue<-ts(YrTimeSeries,frequency=1,start=2006)
library(forecast)
(forecast(tsValue,h=5))
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
2011 86.9993 72.19680 101.8018 64.36083 109.6378
2012 86.9993 66.06645 107.9321 54.98528 119.0133
2013 86.9993 61.36233 112.6363 47.79094 126.2077
2014 86.9993 57.39653 116.6021 41.72576 132.2728
2015 86.9993 53.90256 120.0960 36.38220 137.6164
- The values for Forecasted value(blue line) for each year is same. Can someone please explain me why?
- The 95 % predictive interval is
(36.38220,137.62)
. What does it infer?
回答1:
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")
The 95% predictive interval gives you an interval in which 95% of future observations will lie, assuming that your model is correctly specified.
EDIT: 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))))
来源:https://stackoverflow.com/questions/13063273/in-r-forecasted-values