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 Used11/1/2011 58711/2/2011 57811/3/2011 60011/4/2011 59911/5/2011 67811/6/2011 55511/7/2011 65011/8/2011 70011/9/2011 60011/10/2011 55011/11/2011 60011/12/2011 61011/13/2011 59011/14/2011 59511/15/2011 60111/16/2011 70011/17/2011 65011/18/2011 62011/19/2011 64511/20/2011 65011/21/2011 63911/22/2011 62011/23/2011 60011/24/2011 55011/25/2011 60011/26/2011 61011/27/2011 59011/28/2011 59511/29/2011 60111/30/2011 70012/1/2011 65012/2/2011 62012/3/2011 64512/4/2011 65012/5/2011 63912/6/2011 62012/7/2011 60012/8/2011 55012/9/2011 60012/10/2011 61012/11/2011 59012/12/2011 59512/13/2011 60112/14/2011 70012/15/2011 65012/16/2011 62012/17/2011 64512/18/2011 65012/19/2011 63912/20/2011 62012/21/2011 60012/22/2011 55012/23/2011 60012/24/2011 61012/25/2011 59012/26/2011 75012/27/2011 75012/28/2011 66612/29/2011 67812/30/2011 80012/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?