1
$\begingroup$

Perfoming time series , i faced with problem , namely, terrible quality predictions. Here mydata.

mydat
structure(list(X = 1:29, yearMon = structure(c(11L, 8L, 18L, 
1L, 21L, 16L, 14L, 4L, 28L, 26L, 24L, 6L, 12L, 9L, 19L, 2L, 22L, 
17L, 15L, 5L, 29L, 27L, 25L, 7L, 13L, 10L, 20L, 3L, 23L), .Label = c("Apr-15", 
"Apr-16", "Apr-17", "Aug-15", "Aug-16", "Dec-15", "Dec-16", "Feb-15", 
"Feb-16", "Feb-17", "Jan-15", "Jan-16", "Jan-17", "Jul-15", "Jul-16", 
"Jun-15", "Jun-16", "Mar-15", "Mar-16", "Mar-17", "May-15", "May-16", 
"May-17", "Nov-15", "Nov-16", "Oct-15", "Oct-16", "Sep-15", "Sep-16"
), class = "factor"), Y = c(18175L, 20015L, 48049L, 62826L, 34804L, 
33105L, 38384L, 42316L, 44577L, 24939L, 15908L, 24859L, 13879L, 
18739L, 13202L, 29653L, 30371L, 29638L, 5495L, 56932L, 10910L, 
5906L, 8229L, 2390L, 1020L, 800L, 2630L, 2600L, 70L)), .Names = c("X", 
"yearMon", "Y"), class = "data.frame", row.names = c(NA, -29L
))

i predict for 8 months.

forecast for the next months

library("forecast")
m <- stats::HoltWinters(w)

p = predict(m)
pp = stats:::predict.HoltWinters(m)
p
forecast(m)
test=forecast:::forecast.HoltWinters(m,h=8) #h is how much months do you want to predict
test

as the result, using HW model i get this(minus values are impossible).

> test
         Point Forecast      Lo 80      Hi 80     Lo 95     Hi 95
Jun 2017      6302.7091  -8565.756  21171.175 -16436.65 29042.065
Jul 2017     -1362.2143 -16247.831  13523.402 -24127.80 21403.371
Aug 2017       493.5707 -14430.563  15417.704 -22330.92 23318.063
Sep 2017      1951.3140 -13041.049  16943.677 -20977.53 24880.155
Oct 2017    -17160.9011 -32259.257  -2062.545 -40251.84  5930.042
Nov 2017    -26933.3661 -42183.057 -11683.675 -50255.76 -3610.976
Dec 2017    -19961.5812 -35414.875  -4508.287 -43595.35  3672.192
Jan 2018    -31735.1295 -47450.381 -16019.878 -55769.53 -7700.726

but this can not be, otherwise I'm doing something wrong. What method or techniq should I choose to make the prediction look like the truth?

Because arima-model doesn't work too

Using Arima models

pi=auto.arima(w)
summary(pi)
q=forecast(pi,h=8)
q

my forecast is

         Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
Jun 2017       1989.083 -17265.17 21243.34 -27457.76 31435.92
Jul 2017       1989.083 -18642.28 22620.45 -29563.87 33542.04
Aug 2017       1989.083 -19933.06 23911.23 -31537.94 35516.11
Sep 2017       1989.083 -21151.95 25130.11 -33402.07 37380.24
Oct 2017       1989.083 -22309.77 26287.94 -35172.81 39150.97
Nov 2017       1989.083 -23414.88 27393.05 -36862.93 40841.09
Dec 2017       1989.083 -24473.88 28452.04 -38482.52 42460.69
Jan 2018       1989.083 -25492.10 29470.26 -40039.76 44017.92

of cource is wrong. What i should to do to fit models?

Edit

if i use 2,0,0 structure like in autobox, i get another forecast

kingstimeseriesarima <- arima(w, order=c(2,0,0)) 
q=forecast(kingstimeseriesarima,h=8)
q
  

       Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
May 2017       10137.43 -8639.575 28914.44 -18579.52 38854.38
Jun 2017       13057.40 -7085.025 33199.83 -17747.78 43862.59
Jul 2017       15772.05 -5477.258 37021.36 -16725.96 48270.06
Aug 2017       17438.44 -4213.649 39090.53 -15675.57 50552.45
Sep 2017       18654.80 -3208.775 40518.37 -14782.65 52092.25
Oct 2017       19476.56 -2482.879 41436.00 -14107.50 53060.63
Nov 2017       20050.73 -1955.353 42056.82 -13604.67 53706.14
Dec 2017       20446.01 -1582.146 42474.18 -13243.15 54135.18
$\endgroup$
5
  • $\begingroup$ Relying on the history alone is like trying to drive a car using the rear view mirror. You should be using a causal variable to explain the variability in the past and future values of it to guide the forecast. The causal is like road signs ahead ....."sharp turn ahead" for example. $\endgroup$
    – Tom Reilly
    Apr 16 '18 at 13:03
  • $\begingroup$ Hm. interesting idea. Causal variable is covariate? $\endgroup$
    – D.Joe
    Apr 16 '18 at 13:06
  • $\begingroup$ Yes. Read more about here autobox.com/cms/index.php/afs-university/intro-to-forecasting/… $\endgroup$
    – Tom Reilly
    Apr 16 '18 at 13:17
  • $\begingroup$ Make your data a ts object, not a dataframe. $\endgroup$ Apr 16 '18 at 22:24
  • $\begingroup$ @RobHyndman, yes it is ts object , i just forgot paste this sting where i do w=ts(mydat) $\endgroup$
    – D.Joe
    Apr 17 '18 at 10:28
1
$\begingroup$

The HW model is purely deterministic ... the ARIMA model is purely stochastic(adaptive) ... your data (as does most data ) requires a combination of both deterministic and adaptive structure. Here is a plot of your data showing actual/fit and forecast enter image description here based upon a useful equation which includes arima structure (2,0,0) and 2 pulses and 1 level shift (intercept shift) enter image description here . I used AUTOBOX, an automatic piece of time series software that I have helped to develop. There is an R version available.

The forecasts for the next 8 periods are here ...enter image description here

Identifying the anomalies can often be a precursor to identifying/suggesting the omitted series/effects leading to a potentially useful model that includes causal series

EDIT to show OP what the augmented data matrix looks like with the 3 newly discovered/unearthed variables. enter image description here

$\endgroup$
6
  • $\begingroup$ IrishStat, do you have R code of your autobox desicion? $\endgroup$
    – D.Joe
    Apr 16 '18 at 13:24
  • $\begingroup$ if , i set 2,0,0 structure in R , i don't have result like in your screen kingstimeseriesarima <- arima(w, order=c(2,0,0)) q=forecast(kingstimeseriesarima,h=8) q $\endgroup$
    – D.Joe
    Apr 16 '18 at 13:40
  • $\begingroup$ i edited my post) $\endgroup$
    – D.Joe
    Apr 16 '18 at 13:45
  • $\begingroup$ The reason that you are not duplicating my results is that you have not included the three latent variables that were detected by AUTOBOX viz.. 2 pulses and 1 step/level shift. The R version of the software uses an object to identify the model. $\endgroup$
    – IrishStat
    Apr 16 '18 at 14:16
  • $\begingroup$ Dear, IrishStat, i checked you soft autobox(demo). It is good, but my supervisor wanted that all analytic were performed in R without any another soft. You wrote, that our results are not identical, cause i didn't account pulse and step levelm which autobox discovered. How in R string i can set pulse and level in this string kingstimeseriesarima <- arima(w, order=c(2,0,0)) q=forecast(kingstimeseriesarima,h=8) q $\endgroup$
    – D.Joe
    Apr 17 '18 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.