Search code examples
rdefinitionforecasting

Definition of ARIMA output in r


I have been asked to try and find the parameters from an ARIMA model (µ,Φ,θ) I originally thought that it was just the order of the ARIMA model e.g (1,0,1)(1,1,0) but my manger says this isn't what he wants.

I looked at the summary of the ARIMA model once it had been run and I found values for phi, theta and delta, but there is more than one value and I am very unsure on which is the one I need.

Here is how I found the values:

M<-matrix(c("08Q1", "08Q2", "08Q3", "08Q4", "09Q1", "09Q2", "09Q3", "09Q4", "10Q1", "10Q2", "10Q3", "10Q4", "11Q1", "11Q2", "11Q3", "11Q4", "12Q1",  "12Q2", "12Q3", "12Q4", "13Q1", "13Q2", "13Q3", "13Q4", "14Q1", "14Q2", 79160.56,  91759.73, 91186.48, 106353.82,  70346.47,  80279.15,  82611.60, 131392.72, 93798.99, 105944.78, 103913.13, 154530.69, 110157.40, 117416.09, 127423.42, 156752.00,120097.81, 121307.75, 115021.12, 150657.83, 113711.53, 115353.14, 112701.98, 154319.18,116803.54, 118352.54),ncol=2,byrow=FALSE)
deltaT<-1/4
horiz<-4
startY<-c(8,1)
aslog<-"y"
Nu<-M[,length(M[1,])]
Nu<-as.numeric(Nu)
Nu<-ts(Nu,deltat=deltaT,start=startY)
Mdates<-as.character(M[,1])
if(aslog=="y")
  {N<-log(Nu)} else
    {N<-Nu}
library(forecast)  
library(tseries)
max.sdiff <- 3
arima.force.seasonality <- "n"
suppressWarnings(kpssW <- kpss.test(N, null="Level"))
suppressWarnings(ppW <- tryCatch({ppW <- pp.test(N, alternative = "stationary")},  error = function(ppW) {ppW <- list(error = "TRUE", p.value = 0.99)}))
suppressWarnings(adfW <- adf.test(N, alternative = "stationary", k = trunc((length(N)-1)^(1/3))))
if(kpssW$p.value < 0.05 | ppW$p.value > 0.05 | adfW$p.value > 0.05) {ndiffsW = 1} else {ndiffsW = 0}
aaw <- auto.arima(N, max.D= max.sdiff, d=ndiffsW, seasonal=TRUE, 
                  allowdrift=FALSE, stepwise=FALSE, trace=FALSE, seasonal.test="ch")
orderWA <- c(aaw$arma[1], aaw$arma[6] , aaw$arma[2])
orderWS <- c(aaw$arma[3], aaw$arma[7] , aaw$arma[4])
if(sum(aaw$arma[1:2])==0) {orderWA[1] <- 1} else {NULL}
if(arima.force.seasonality == "y") {if(sum(aaw$arma[3:4])==0) {orderWS[1] <- 1} else {NULL}} else {NULL}
ArimaW1 <- Arima(N, order= orderWA, seasonal=list(order=orderWS), method="ML")
ArimaW1$model

This shows 5 different values for phi, 4 for theta and 1 for Delta. How do I know which is the correct parameter value? Or do I use all of them to show the parameters and also force the parameters on a truncated version of my data to test the accuracy of the fit?


Solution

  • You can get the fitted coefficients using the coef function:

    coef(ArimaW1)
        ar1       sar1       sma1 
    -0.1535883  0.9898988 -0.6517680 
    

    These are equal to the coefficients that are displayed when summary(ArimaW1) or just ArimaW1 is run. If the model is of the form ARIMA(p,d,q)(P,D,Q)[m], then:

    • p = ar coefficient(s)
    • q = ma coefficient(s)
    • P = sar coefficient(s)
    • Q = sma coefficient(s)

    The accuracy of the fit that is part of the output from summary(ArimaW1) can be assessed using the forecast::accuracy function:

    accuracy(ArimaW1)
                          ME      RMSE        MAE        MPE      MAPE      MASE
    Training set 0.005871904 0.0812424 0.05851961 0.04856836 0.5022439 0.3297573
                       ACF1
    Training set 0.03194607 
    

    I think (i.e. guess) that the multiple coefficient values you found in ArimaW1$model are leftovers from the fitting via MLE. If you run debugonce(Arima) you can see that during the fitting the coefficients in mod, which gets returned as fit$model, change (but I think only once or twice).

    By the way, if you are looking for a quick introduction to seasonal ARIMA models using R Forecasting: Principles And Practice is worth a recommendation.