3
$\begingroup$

Using the attached data that has been recently updated I am not able to obtain a statistically significant forecast. The data is extremely seasonal. The data is stored here for easy replication:

http://ge.tt/1uihVfA2/v/0?c

# 1. Make a R timeseries out of the rawdata: specify frequency & startdate
gIIP <- ts(Data, frequency=12, start=c(2003,11))
print(gIIP)
plot.ts(gIIP, type="l", col="blue", ylab="MTD Ships", lwd=2,
        main="Full data")
grid()

Using the auto.arima function I don't need to factor a Box-Cox because the auto.arima factors that into selecting the best model.

Upon "selecting the best model" I The best model suggested was Arima(order = c(0, 0, 1), seasonal = list(order = c(1, 0, 1), period = 12) with non-zero mean

# 5. Perform estimation
library(forecast)
library(zoo)
library(stats)
auto.arima(gIIP, d=NA, D=NA, max.p=12, max.q=12,
           max.P=2, max.Q=2, max.order=12, max.d=2, max.D=2,
           start.p=2, start.q=2, start.P=1, start.Q=1,
           stationary=FALSE, seasonal=TRUE,
           ic=c("aicc","aic", "bic"), stepwise=FALSE, trace=TRUE,
           approximation=FALSE | frequency(gIIP)>12), xreg=NULL,
           test=c("kpss","adf","pp"), seasonal.test=c("ocsb","ch"),
           allowdrift=TRUE, lambda=TRUE, parallel=FALSE, num.cores=4

)

then proceed to conduct accuracy diagnostics but unable to obtain any output.

#Check standard error etc of "fitted" ARIMA
pos.arima <- function(gIIP, order = c(0, 0, 1),
      seasonal = list(order = c(1, 0, 1), period = 12),
      xreg = NULL, include.drift=TRUE, 
      transform.pars = TRUE,
      fixed = NULL, init = NULL,
      method = c("CSS-ML", "ML", "CSS"), 
      optim.method = "BFGS",
      optim.control = list(), kappa = 1e6)

acf(pos.arima) 
pacf(pos.arima)

The following step to conduct an ex ante (out of sample forecast) but also unable to obtain a statistically significant forecast---forecast with lowest standard error rate. I tested this by removing the last 5 observations to test the model.

# 7. Forecast Out-Of-Sample ---this used to work
fit <- Arima(gIIP, order = c(0, 0, 1), seasonal = list(order = c(1, 0, 1), period = 12),
             xreg = TRUE, include.mean = TRUE, transform.pars = TRUE, 
             fixed = NULL, init = NULL, method = c("CSS-ML", "ML", "CSS"), 
             optim.method = "BFGS", optim.control = list(), kappa = 1e6)
plot(forecast(fit,h=9))
print(forecast(fit,h=9))

Used to obtain output here. Can you please help me diagnose why there ARIMA model is not working like it once did for me? Thank you for your time.

$\endgroup$
  • $\begingroup$ Your data has outliers such as pulses and level shifts, you need to treat these if you are applying ARIMA models. $\endgroup$ – forecaster Feb 17 '15 at 23:14
  • $\begingroup$ @forecaster Hi forecaster, the data is extremely seasonal usually the peak months--the apex are in March & April. I am not sure how I'd apply a dummy variable factoring the apex annual peak months or if it would be appropriate. $\endgroup$ – Jim Johnson Feb 17 '15 at 23:20
  • $\begingroup$ No, I'm not suggesting to use dummy variables for seasonal variation, but for outliers. There are specialists in this website, I hope they respond to your question. I'll try to put something together in next few days if I find time. $\endgroup$ – forecaster Feb 17 '15 at 23:24
  • $\begingroup$ I was able to use auto.arima after I uninstalled R 3.41 and installed R.3.4.1 version $\endgroup$ – Prasad K Dec 7 '17 at 3:08
4
$\begingroup$

The basic problem in your data is that it has outliers, not treating them are at least understanding what/where the outliers are present might lead to poor predictions.

There is a package in R called tsoutliers which implements Chen and Liu that can help you diagnose outliers in the data. Commercial packages such as Autobox which uses Tsay's outlier detection also has excellent outlier detection capabilities. I'll expand my answer in the next few days bear with me.

I used tso function in tsoutliers package to detect outliers

datats <- ts(data,start=c(2003,11),frequency=12)
plot.ts(datats)

c  <- tso(datats, types = c("AO", "LS","SLS"))
plot(c)

Below are the outputs:

Outliers:
  type ind    time  coefhat tstat
1  SLS  18 2005:04 16923128 6.765
2   AO 101 2012:03 36590158 4.763
3  SLS 112 2013:02 21989974 4.096
4  SLS 113 2013:03 25225304 4.699
5   AO 115 2013:05 24259786 3.158

In looking at your data, there is an additive outlier at observation 2012:03 and seasonal level shift around 2013:02. You can practically ignore seasonal level shift at 2005:04. tsoutliers provides nice graphical output that shows some instability in the last few years 2012/2013/2014, that is seasonal variation has changed. If you do not account for it,then you are bound to produce poor forecasts.

enter image description here

$\endgroup$
  • $\begingroup$ okay, thank you for your response. I'll wait for the rest of your explanation. Thanks again!! $\endgroup$ – Jim Johnson Feb 18 '15 at 16:12
1
$\begingroup$

An analysis of this data using AUTOBOX http://www.autobox.com/cms/ (a piece of software that I have helped develop) led to an ARIMA model that evidenced significant instability with respect to it's model parameters as @forecaster had correctly suggested. I followed the paradigm of developing an ARIMA model first as compared to the alternative of detecting Interventions first as that is what the OP did. The software used the CHOW test to discover that the first 45 observations produced a statistically significant difference in parameters versus the last 85. This is NOW visually obvious once the analysis generated that hypothesis is presented. The human eye is no match for good analysis ! The model for the most recent 85 values was automatically developed using the iterative (not list-based) method of Box and Jenkins enter image description here (1,0,0)(0,1,0)12 with an outlier at period 101. The reason that the op's model being problematic with outliers and such was a fundamental alteration in the model coefficients. The plot of actual/fit/forecats is here enter image description here with forecast plot here enter image description here showing the 5 retained values. An analysis of the forecast errors is here enter image description here . Note that this is just 1 snapshot and may not be totally representative but it looks good to me . Finally the plot of the residuals is here enter image description here with an acf of enter image description here suggesting that the model for the last 85 observations might be adequate.

$\endgroup$
  • $\begingroup$ I intuitively thought about not using some of the earlier data points due to the number of significant changes that have occurred the past 5 years. Thanks for the insight. $\endgroup$ – Jim Johnson Feb 18 '15 at 16:16
  • $\begingroup$ The intuition DID NOT come from me but rather some software/code that I wrote that implemented the ides of people/statisticians far smarter than I. Glad to be of some help. $\endgroup$ – IrishStat Feb 21 '15 at 20:38

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.