1

I use auto.arima function in R to fit a TS model to a annual data composed of electricity demand. The series is transformed w.r.t Box-Cox lambda due to the prevailing heteroscedasticity and then it is twiced differenced to eliminate the trend in the data. The first ACF/PACF plot (w/o transformation) suggest that an ARIMA model should be fitted to the model; whereas the second ACF/PACF (with transformation) plot suggests that an AR model should be fitted. However both of them depend on the same data. In both of the case, the auto.arima function selects the best model as ARIMA(1,2,1) which can be expected according to the first plot but not according to the second plot due to the one spike in PACF.

untransformed transformed

dmnd=c(8.6,9.8,11.2,12.4,13.5,15.7,18.6,21.1,22.3,23.6,24.6,26.3,28.3,29.6,33.3,36.4,40.5,44.9,48.4,52.6,56.8,60.5,67.2,73.4,77.8,85.6,94.8,105.5,

114.0,118.5,128.3,126.9,132.6,141.2,150.0,160.8,174.6,190.0,198.1,194.1,210.4,230.3,242.4,246.4,257.2)

x=ts(dmnd,frequency=1)

sdx=diff(x,differences = 2)
x1<-acf(sdx,length(sdx),ylab="Sample ACF",main ="")
x2<-pacf(sdx,length(sdx),ylab="Sample PACF",main ="")

library(FitAR)

#transformation
fit=arima(x,order=c(0,2,0))
BoxCox(fit, interval = c(-1, 1), type = "BoxCox")

library(forecast)
tx=BoxCox(x, -0.049)

sdx=diff(tx,differences = 2)
x1<-acf(sdx,length(sdx),ylab="Sample ACF",main ="")
x2<-pacf(sdx,length(sdx),ylab="Sample PACF",main ="")


fit=auto.arima(x,d = 2,D = 0,start.p=0, start.q=0, max.p=5, max.q=5,stationary=FALSE,seasonal=FALSE,stepwise=TRUE,trace=TRUE,approximation=FALSE,allowdrift=TRUE,ic="aicc",lambda=-0.049)

par(mfrow=c(1,2)) 
x1<-acf(fit$residuals,length(fit$residuals),ylab="Sample ACF",main ="")
x2<-pacf(fit$residuals,length(fit$residuals),ylab="Sample PACF",main ="")

Box.test(fit$residuals, lag = length(fit$residuals)/5, type = c("Ljung-Box"), fitdf = length(fit$ coef))

shapiro.test(fit$residuals)

library(TSA)
x.standard=rstandard.Arima(fit)
qqnorm(x.standard,main ="")
qqline(x.standard)

Results of ARIMA(3,1,0) Model

Summary

sample ACF/PACf Normality

Shapiro-Wilk normality test

data:  fit$residuals
W = 0.8557, p-value = 5.153e-05

Box-Ljung test

data:  fit$residuals
X-squared = 14.2044, df = 6, p-value = 0.02743

Diagnostics of Residuals ARIMA(1,1,1) transformed ACF/PACF Normal

auto.arima result for the series without the observations "32, 40, 41" without some observation

Dirk
  • 213
  • 2
  • 7
  • 1
    You might want to share the data as optimal Box-Cox transforms should be based upon the residuals from a useful model not necessarily the original series. . – IrishStat Aug 30 '15 at 22:01
  • @IrishStat There exists dispersion in the original data so the transformformation should be carried out. I posted the data and the codes that I use. – Dirk Aug 30 '15 at 22:40
  • Dispersion in the original data may be caused by unusual values , changes in model parameters over time etc. Either way the requirements for the F Test and the T test are that the errors from a model have constant variance not that the errors around a simple mean have constant variance. When you analyze the original series you are implicitely assuming a simple mean is the best model. I will look at your data. – IrishStat Aug 30 '15 at 23:39
  • 1
    I should also comment that variance change can sometimes be at a particular points in time culminating in Weighted Least Squares.. Box - Cox transforms remedies linkage between the expected value of Y and the dispersion in the error process. The treat different non-constant error variance symptoms. – IrishStat Aug 31 '15 at 02:01
  • @IrishStat The forecasts does not seem better without the transformations. Well, I think that the sample ACF and PACF does not always reflect the theoretical patterns. If the model is chosen based on AICc and the diagnostic tests are satisfied, the box-cox transformed model is adequate. – Dirk Aug 31 '15 at 13:15
  • The sample acf/pacf of the original series are flawed due to the outliers in the series. The aic selection criteria is flawed because it is list-based and doesn't take into account the anomalies. Look at the residuals from your model and you will be surprised as to how non-gussian (white) they look. Evaluating a model base upon how the forecasts "look" from a single origin is quite unscientific in my opinion as it is simply a sample of 1 but they look good to me. – IrishStat Aug 31 '15 at 13:26
  • notice how your ar(2) coefficient is not significant ? and your residual plot (not shown by you) will have three spikes/anomalies – IrishStat Aug 31 '15 at 14:06
  • @IrishStat I edited the codes for diagnostics in the post. The model passes all tests. – Dirk Aug 31 '15 at 14:22
  • why don't you post the residuals or at least plot them just to make sure that you ok – IrishStat Aug 31 '15 at 18:45
  • @IrishStat I' ve edited them. They look very nice. – Dirk Aug 31 '15 at 18:54
  • Perhaps I can take another tack ...Since you have not incorporated the three pulse indicators (40,32 and 41) their effect remains in the residuals. Thus the variance of the residuals is grossly inflated by these three effects thus the acf is downwards biased because the acf is the ratio of the co-variance to the (inflated) variance. This is euphamistically called the "Alice in Wonderland Effect" . – IrishStat Aug 31 '15 at 20:14
  • @IrishStat I deleted the corresponding observations ("outliers"). The result is the same without transformation. No luck for ARIMA(3,1,0) model. It is an overfitted model. – Dirk Aug 31 '15 at 20:32
  • You can't delete observations because your are effecting the the estimation of the ARIMA parameters. If anything you would adjust the three observations (in log space) using the parameters reported in the AUTOBOX output. – IrishStat Aug 31 '15 at 20:45
  • @IrishStat Ok ! I' ve never heard of that kind of adjustment. I cannot check that result from AUTOBOX; since I dont have the algorithms. If u can provide me these three adjusted values, I can check it with auto.arima. But I dont think that the result will be different. 3 in 45 observations. – Dirk Aug 31 '15 at 21:36
  • time period 40 194.10×Comments must be at least 15 characters in length.×Comments must be at least 15 characters in length.×Comments must be at least 15 characters in length. I will try and get back to you – IrishStat Aug 31 '15 at 21:45
  • AUTOBOX does not report the adjusted values when dealing with a power transform . You should be able to "see" the need for special treatment (however slight in the original metric in the plot of the residuals against time. – IrishStat Aug 31 '15 at 22:25
  • You say this: "*The series is twiced difference to eliminate the trend in the data.* ***After that*** *the data is transformed w.r.t Box-Cox lambda due to the prevailing heteroscedasticity.*" ... which clearly states the data are twice differenced first, then transformed. Then you say this: "*Note that the data are first transformed, then twice differenced*" ... which directly contradicts the sentence before it. Which statement is wrong? – Glen_b Nov 18 '15 at 15:45
  • @Glen_b Yes,sorry, the text is misleading. The time series is first transformed and then differenced. Vice Versa is not also a problem in this case. The data resembles a non-increasing monotone function. t(i-x) is always greater than t(i-x+1). – Dirk Nov 27 '15 at 15:21

1 Answers1

1

I took your data (45 observations) into AUTOBOX ( a piece of software that I have helped develop) and it automatically tested for a deterministic change in error and optionally for a Box-Cox transformation. The preferred model is here logs being found to be optimal enter image description here . When and where to apply Box-Cox is here When (and why) should you take the log of a distribution (of numbers)? . The acf of the residuals from this hybrid model enter image description here and the plot of actual/fit/forecast is here enter image description here . The forecasts are shown here enter image description here . The conclusion that only first differences are needed along with an AR(3) polynomial (without lag2 ) and three pulse indicators at (32,40 and 41)

REVISED TO EXPLAIN THE FLAW OF TRANSFORMING BASED UPON THE ORIGINAL SERIES:

One last time ..... Perhaps this wlll help you understand the (sometimes) fatal flaw of determining the transform based upon the original series. http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation starting at slide 58. It shows the classic AIRLINE series incorrectly transformed because the original series was studied (thus no model in place) . The original series suitably differenced and fitted with a simple ARIMA model yielded a few outliers that untreated inadvertently led to an uneeded log transformation. You are not alone in this misunderstanding as is detailed by the approach taken by the majority of software vendors.

A detailed discussion of other vendors approach and too many textbooks to mention is here http://www.autobox.com/pdfs/vegas_ibf_09a.pdf

IrishStat
  • 27,906
  • 5
  • 29
  • 55
  • I appreciate your comments. Thx. Sure, the outliers are not considered in AICc or in the model list. I couldn't get what AR(3) polynomial (without lag2 ) means. But I computed ARIMA(3,1,0) by using R. There is no way to validate the corresponding model for adequacy both visually and analytically (also an overfitted model). – Dirk Aug 31 '15 at 14:16
  • In your post, I also recognized that one value is at the limit in ACF plot. But the box-cox transformed series is validated for adequacy. I haven't found a TSA model that can be adequately fitted to the series without transformation (once or twice differenced). In general, if the original series is not homoscedastic and normally distributed, I doubt that the residuals will be homoscedastic and normally distributed. – Dirk Aug 31 '15 at 14:16
  • 2
    You can doubt all you want but I can guarantee you that the correct thing to do is to ensure that the errors are normally distributed ..but what do I know as I have only been involved(solely) for the last 48 years. – IrishStat Aug 31 '15 at 18:47
  • I respect that. I posted the ACF/PACF and Q-Q plot. Also, I posted the codes. If u try, u will get the same results. In this case, transformation is necessary. – Dirk Aug 31 '15 at 19:02