I've done some research and I am stuck in finding the solution. I have a time series data, very basic data frame, let's call it x
:
Date Used
11/1/2011 587
11/2/2011 578
11/3/2011 600
11/4/2011 599
11/5/2011 678
11/6/2011 555
11/7/2011 650
11/8/2011 700
11/9/2011 600
11/10/2011 550
11/11/2011 600
11/12/2011 610
11/13/2011 590
11/14/2011 595
11/15/2011 601
11/16/2011 700
11/17/2011 650
11/18/2011 620
11/19/2011 645
11/20/2011 650
11/21/2011 639
11/22/2011 620
11/23/2011 600
11/24/2011 550
11/25/2011 600
11/26/2011 610
11/27/2011 590
11/28/2011 595
11/29/2011 601
11/30/2011 700
12/1/2011 650
12/2/2011 620
12/3/2011 645
12/4/2011 650
12/5/2011 639
12/6/2011 620
12/7/2011 600
12/8/2011 550
12/9/2011 600
12/10/2011 610
12/11/2011 590
12/12/2011 595
12/13/2011 601
12/14/2011 700
12/15/2011 650
12/16/2011 620
12/17/2011 645
12/18/2011 650
12/19/2011 639
12/20/2011 620
12/21/2011 600
12/22/2011 550
12/23/2011 600
12/24/2011 610
12/25/2011 590
12/26/2011 750
12/27/2011 750
12/28/2011 666
12/29/2011 678
12/30/2011 800
12/31/2011 750
I really appreciate any help with this. I am working with time series data and need to be able to create forecast based on historical data.
First I tried to convert it to
xts
:x.xts <- xts(x$Used, x$Date)
Then, I converted
x.xts
to regular time series:x.ts <- as.ts(x.xts)
Put the values in
ets
:x.ets <- ets(x.ts)
Performed forecasting for 10 periods:
x.fore <- forecast(x.ets, h=10)
x.fore
is this:Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 87 932.9199 831.7766 1034.063 778.2346 1087.605 88 932.9199 818.1745 1047.665 757.4319 1108.408 89 932.9199 805.9985 1059.841 738.8103 1127.029 90 932.9199 794.8706 1070.969 721.7918 1144.048 91 932.9199 784.5550 1081.285 706.0153 1159.824 92 932.9199 774.8922 1090.948 691.2375 1174.602 93 932.9199 765.7692 1100.071 677.2849 1188.555 94 932.9199 757.1017 1108.738 664.0292 1201.811 95 932.9199 748.8254 1117.014 651.3717 1214.468 96 932.9199 740.8897 1124.950 639.2351 1226.605
When I try to plot the
x.fore
, I get a graph but the x-axis is showing numbers rather than dates:
Are the steps I am doing correct? How can I change the x-axis to read show dates?
I thank you so much for any input.
install.packages("forecast"); library("sos"); findFn("forecast"); findFn("forecast time-series")
– Matteo?dput
can help you provide us with a reproducible example: see tinyurl.com/reproducible-000 ) ... – Matteo