i new r package , dealing time series. have build prediction model forecasting clicks future. time interval prediction needs hourly.
my example time series:
datetime clicks (06/23/13 00:00:00) 757 (06/23/13 01:00:00) 714 (06/23/13 02:00:00) 776 (06/23/13 03:00:00) 870 (06/23/13 04:00:00) 1263 (06/23/13 05:00:00) 1457 (06/23/13 06:00:00) 1621 (06/23/13 07:00:00) 1606 (06/23/13 08:00:00) 1779 (06/23/13 09:00:00) 1832 (06/23/13 10:00:00) 1808 (06/23/13 11:00:00) 1789 (06/23/13 12:00:00) 1907 (06/23/13 13:00:00) 2021 (06/23/13 14:00:00) 2018 (06/23/13 15:00:00) 1836 (06/23/13 16:00:00) 1627 (06/23/13 17:00:00) 1331 (06/23/13 18:00:00) 1059 (06/23/13 19:00:00) 817 (06/23/13 20:00:00) 761 (06/23/13 21:00:00) 781 (06/23/13 22:00:00) 752 (06/23/13 23:00:00) 725 (06/24/13 00:00:00) 708 (06/24/13 01:00:00) 718 (06/24/13 02:00:00) 791 (06/24/13 03:00:00) 857 (06/24/13 04:00:00) 1094 (06/24/13 05:00:00) 1247 (06/24/13 06:00:00) 1316 (06/24/13 07:00:00) 1401 (06/24/13 08:00:00) 1575 (06/24/13 09:00:00) 1604 (06/24/13 10:00:00) 1774 (06/24/13 11:00:00) 1865 (06/24/13 12:00:00) 1964 (06/24/13 13:00:00) 2002 (06/24/13 14:00:00) 2043 (06/24/13 15:00:00) 2030 (06/24/13 16:00:00) 1733 (06/24/13 17:00:00) 1420 (06/24/13 18:00:00) 1075 (06/24/13 19:00:00) 831 (06/24/13 20:00:00) 789 (06/24/13 21:00:00) 791 (06/24/13 22:00:00) 715 (06/24/13 23:00:00) 683 (06/25/13 00:00:00) 802 (06/25/13 01:00:00) 811 (06/25/13 02:00:00) 838 (06/25/13 03:00:00) 851 (06/25/13 04:00:00) 1064 (06/25/13 05:00:00) 1191 (06/25/13 06:00:00) 1242 (06/25/13 07:00:00) 1233 (06/25/13 08:00:00) 1452 (06/25/13 09:00:00) 1501 (06/25/13 10:00:00) 1718 (06/25/13 11:00:00) 1861 (06/25/13 12:00:00) 1896 (06/25/13 13:00:00) 2073 (06/25/13 14:00:00) 2279 (06/25/13 15:00:00) 2239 (06/25/13 16:00:00) 2018 (06/25/13 17:00:00) 1550 (06/25/13 18:00:00) 1182 (06/25/13 19:00:00) 1063 (06/25/13 20:00:00) 973 (06/25/13 21:00:00) 1027 (06/25/13 22:00:00) 961 (06/25/13 23:00:00) 890 (06/26/13 00:00:00) 894 (06/26/13 01:00:00) 835 (06/26/13 02:00:00) 852 (06/26/13 03:00:00) 893 (06/26/13 04:00:00) 1111 (06/26/13 05:00:00) 1239 (06/26/13 06:00:00) 1263 (06/26/13 07:00:00) 1260 (06/26/13 08:00:00) 1451 (06/26/13 09:00:00) 1556 (06/26/13 10:00:00) 1733 (06/26/13 11:00:00) 1981 (06/26/13 12:00:00) 2063 (06/26/13 13:00:00) 2150 (06/26/13 14:00:00) 2278 (06/26/13 15:00:00) 2188 (06/26/13 16:00:00) 1980 (06/26/13 17:00:00) 1611 (06/26/13 18:00:00) 1381 (06/26/13 19:00:00) 1211 (06/26/13 20:00:00) 1129 (06/26/13 21:00:00) 1092 (06/26/13 22:00:00) 1009 (06/26/13 23:00:00) 973 (06/27/13 00:00:00) 865 (06/27/13 01:00:00) 805 (06/27/13 02:00:00) 840 (06/27/13 03:00:00) 813 (06/27/13 04:00:00) 1010 (06/27/13 05:00:00) 1201 (06/27/13 06:00:00) 1329 (06/27/13 07:00:00) 1343 (06/27/13 08:00:00) 1532 (06/27/13 09:00:00) 1612 (06/27/13 10:00:00) 1768 (06/27/13 11:00:00) 1977 (06/27/13 12:00:00) 2089 (06/27/13 13:00:00) 2247 (06/27/13 14:00:00) 2270 (06/27/13 15:00:00) 2275 (06/27/13 16:00:00) 2155 (06/27/13 17:00:00) 1639 (06/27/13 18:00:00) 1315 (06/27/13 19:00:00) 1099 (06/27/13 20:00:00) 1052 (06/27/13 21:00:00) 1099 (06/27/13 22:00:00) 965 (06/27/13 23:00:00) 961 (06/28/13 00:00:00) 765 (06/28/13 01:00:00) 830 (06/28/13 02:00:00) 874 (06/28/13 03:00:00) 845 (06/28/13 04:00:00) 1011 (06/28/13 05:00:00) 1160 (06/28/13 06:00:00) 1232 (06/28/13 07:00:00) 1310 (06/28/13 08:00:00) 1467 (06/28/13 09:00:00) 1639 (06/28/13 10:00:00) 1704 (06/28/13 11:00:00) 3704 (06/28/13 12:00:00) 7350 (06/28/13 13:00:00) 7629 (06/28/13 14:00:00) 7570 (06/28/13 15:00:00) 7276 (06/28/13 16:00:00) 7189 (06/28/13 17:00:00) 7139 (06/28/13 18:00:00) 7167 (06/28/13 19:00:00) 6871 (06/28/13 20:00:00) 6575 (06/28/13 21:00:00) 6112 (06/28/13 22:00:00) 5276 (06/28/13 23:00:00) 4407 (06/29/13 00:00:00) 3741 (06/29/13 01:00:00) 3427 (06/29/13 02:00:00) 3311 (06/29/13 03:00:00) 3096 (06/29/13 04:00:00) 3010 (06/29/13 05:00:00) 3301 (06/29/13 06:00:00) 3783 (06/29/13 07:00:00) 4578 (06/29/13 08:00:00) 5599 (06/29/13 09:00:00) 6590 (06/29/13 10:00:00) 6998 (06/29/13 11:00:00) 7323 (06/29/13 12:00:00) 7282 (06/29/13 13:00:00) 7009 (06/29/13 14:00:00) 6636 (06/29/13 15:00:00) 6407 (06/29/13 16:00:00) 6386 (06/29/13 17:00:00) 6505 (06/29/13 18:00:00) 3104 (06/29/13 19:00:00) 939 (06/29/13 20:00:00) 915 (06/29/13 21:00:00) 955 (06/29/13 22:00:00) 968 (06/29/13 23:00:00) 870 (06/30/13 00:00:00) 3504 (06/30/13 01:00:00) 3122 (06/30/13 02:00:00) 2874 (06/30/13 03:00:00) 2613 (06/30/13 04:00:00) 2905 (06/30/13 05:00:00) 2806 (06/30/13 06:00:00) 3244 (06/30/13 07:00:00) 3789 (06/30/13 08:00:00) 5015 (06/30/13 09:00:00) 6031 (06/30/13 10:00:00) 6841 (06/30/13 11:00:00) 7014 (06/30/13 12:00:00) 7265 (06/30/13 13:00:00) 7460 (06/30/13 14:00:00) 7275 (06/30/13 15:00:00) 7531 (06/30/13 16:00:00) 7013 (06/30/13 17:00:00) 6637 (06/30/13 18:00:00) 5770 (06/30/13 19:00:00) 5593 (06/30/13 20:00:00) 6524 (06/30/13 21:00:00) 5081 (06/30/13 22:00:00) 1131 (06/30/13 23:00:00) 949
this time series whole week on hourly basis. considering data need predict using holt-winters number of clicks obtained next hour i.e. (06/28/13 00:00:00). trying figure out getting confused. thankful if can point me right direction.
edit:
i using holt-winters predict module follows:
search_fit <- holtwinters(z) p = predict(search_fit,24)
but problem holt-winters not detecting trend in prediction. normal? because there big change starting 06/28/13.
following predicted values:
time series: start = c(15887, 1) end = c(15887, 24) frequency = 24 fit [1,] 927.6462 [2,] 935.2716 [3,] 1006.5636 [4,] 1066.4182 [5,] 1295.5852 [6,] 1442.9397 [7,] 1508.1693 [8,] 1590.9613 [9,] 1762.5033 [10,] 1789.1287 [11,] 1958.1083 [12,] 2049.1711 [13,] 2054.7757 [14,] 2168.1302 [15,] 2163.1514 [16,] 1979.5268 [17,] 1772.7355 [18,] 1483.0484 [19,] 1220.1946 [20,] 987.2366 [21,] 938.1745 [22,] 965.5915 [23,] 940.4669 [24,] 911.0089
and prediction plot.
the trend component shows no variation. there might doing wrong while using predict method of holt-winters.
here suggestions/things try:
one reason not seeing holtwinters
pick trend change referring (on 6/28/13 in data) manifesting in level component. clicks have changed materially starting noon on 6/28.
one note: holtwinters()
spit out smoothing parameters (alpha, beta, gamma). give slope b. if beta 0, means trend does not change on time series. started slope b, , continues @ same slope.
things try
try this:
> library(forecast) > accuracy(search_fit)
also idea check auto-correlations:
> acf(search_fit$residuals, lag.max=24)
a few general comments might analysis
- in addition holtwinters (exponential smoothing), might want arima methods. rob hyndman states @ start of chapter 8 of textbook:
exponential smoothing , arima models 2 widely-used approaches time series forecasting, , provide complementary approaches problem. while exponential smoothing models based on description of trend , seasonality in data, arima models aim describe autocorrelations in data.
as quick starting reference find 1.avril coghlan's little book of r time series great primer. also, 2. time series analysis r - part i great, little more technical detail.
as , when find time, reading prof. rob hyndman's book forecasting principles , practice online worth time, who's going doing time series analysis.
be sure try
forecast
package well.auto.arima()
function incredible time saver.
hope helps.
Comments
Post a Comment