简体   繁体   中英

How to get number from holt-winters forecast in Rstudio

Like the title said, is there anyway to get an exact number from a Holt-winters forecast? For example, say I have a time-series object like this:

Date    Total  
6/1/2014    150  
7/1/2014    219  
8/1/2014    214  
9/1/2014    47  
10/1/2014   311  
11/1/2014   198  
12/1/2014   169  
1/1/2015    253  
2/1/2015    167  
3/1/2015    262  
4/1/2015    290  
5/1/2015    319  
6/1/2015    405  
7/1/2015    395  
8/1/2015    391  
9/1/2015    345  
10/1/2015   401  
11/1/2015   390  
12/1/2015   417  
1/1/2016    375  
2/1/2016    397  
3/1/2016    802  
4/1/2016    466  

After storing it in variable hp, I used Holt Winters to make a forecast:

hp.ts <- ts(hp$Total, frequency = 12, start = c(2014,4))   
hp.ts.hw <- HoltWinters(hp.ts)   
library(forecast)   
hp.ts.hw.fc <- forecast.HoltWinters(hp.ts.hw, h = 5)   
plot(hp.ts.hw.fc)

However, what I need to know is how exactly the Total in 2016/05 is (predictly) going to be. Is there anyway to get the exact value?

By the way, I noticed that the blue (forecast) line is NOT connected to the black line. Is that normal? Or I should fix my code?

Thank you for reading.

I don't know why you went round around while you have called the library(forecast). Below provides direct answers for your questions:

hp.ts.hw <- hw(hp.ts)
hp.ts.hw.fc <- forecast(hp.ts.hw, h = 5)
plot(hp.ts.hw.fc)
hp.ts.hw.fc

         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Mar 2016       546.5311 448.2997 644.7624 396.2992 696.7630
Apr 2016       623.7030 525.4716 721.9344 473.4711 773.9349
May 2016       671.8989 573.6675 770.1303 521.6670 822.1309
Jun 2016       667.3722 569.1408 765.6036 517.1402 817.6041
Jul 2016       500.0710 401.8396 598.3024 349.8390 650.3030

I'm not sure if I understood your doubt. But you can get the forecasted value by:

hp.ts.hw.fc$mean

You can use accuracy function to measure how good is your results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM