1
$\begingroup$

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

$\endgroup$
  • 1
    $\begingroup$ 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. . $\endgroup$ – IrishStat Aug 30 '15 at 22:01
  • $\begingroup$ @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. $\endgroup$ – Dirk Aug 30 '15 at 22:40
  • $\begingroup$ 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. $\endgroup$ – IrishStat Aug 30 '15 at 23:39
  • 1
    $\begingroup$ 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. $\endgroup$ – IrishStat Aug 31 '15 at 2:01
  • $\begingroup$ @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. $\endgroup$ – Dirk Aug 31 '15 at 13:15
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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). $\endgroup$ – Dirk Aug 31 '15 at 14:16
  • $\begingroup$ 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. $\endgroup$ – Dirk Aug 31 '15 at 14:16
  • 2
    $\begingroup$ 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. $\endgroup$ – IrishStat Aug 31 '15 at 18:47
  • $\begingroup$ 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. $\endgroup$ – Dirk Aug 31 '15 at 19:02

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.