5

I applied ARIMA to a time-series dataset (dataset).

In order to archive stationary, I applied the following steps:

  1. log transformation log_dataset <- log(dataset)
  2. difflog_dataset <- diff(log_dataset,1) to my dataset.
  3. I tested stationary by Ljung-Box.

I fitted difflog_dataset by ARIMA(1,0,2) adequately.

fit <- Arima(difflog_dataset, order=c(1,0,2))

Do I need to de-transformation from fitted(fit) to get $\hat{y}$ value? How can I do that ?

lotusirous
  • 245
  • 2
  • 11
  • The inverse operation of differentiation is integration. Or, for your discrete problem the cumulative sum, i.e., R function `cumsum`. However, differentiation is not lossless: you lose any information about an offset (a constant). Are you doing forecasting? – Roland Jan 02 '17 at 07:29
  • You may use ARIMA(1,1,2) that is equivalent to diff(log_dataset,1), as 1 in the middle, roughly speaking, states for the difference order. Then just apply exp($\hat{y}$) in order to get right values. – Bogdan Jan 02 '17 at 07:30
  • @Roland. Yes, I'm using time series for forecasting. – lotusirous Jan 02 '17 at 09:19
  • Why did you feel it was necessary to take logs in the first place http://stats.stackexchange.com/questions/18844/when-and-why-should-you-take-the-log-of-a-distribution-of-numbers . Differencing a series to deal with a form of non-stationarity is one thing taking a power transform is often unwarranted http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation ...slide 61- – IrishStat Jan 02 '17 at 18:55

1 Answers1

6

Say your original series is $y_t$ and you define the transformed series:

$$\tilde{y}_t = \log(y_t)-\log(y_{t-1})$$

You then forecast the value of $\tilde{y}_{t+1}$ by using your ARIMA(1,0,2) model, giving you $\hat{\tilde{y}}_{t+1}$, but you want a forecast of $y_{t+1}$. You can compute it like this:

$$\hat{y}_{t+1} = y_t \exp\left({\hat{\tilde{y}}_{t+1}}\right)$$

More generally, you can verify that the following telescoping sum:

$$\log(y_t) = \log(y_0) + \sum_{i=1}^t \left(\log(y_i)-\log(y_{i-1})\right)$$

implies that the inverse transformation is:

$$y_t = y_0 \exp{\left(\sum_{i=1}^t \tilde{y}_i\right)}$$

As a practical matter, the forecast::Arima function you are using will do all of this for you if you specify both the log-transform and the difference in the function call, instead of doing it by hand before calling it:

fit <- Arima(dataset, order=c(1,1,2), lambda=0)
Chris Haug
  • 4,893
  • 1
  • 17
  • 24