36
$\begingroup$

I have previously used forecast pro to forecast univariate time series, but am switching my workflow over to R. The forecast package for R contains a lot of useful functions, but one thing it doesn't do is any kind of data transformation before running auto.arima(). In some cases forecast pro decides to log transform data before doing forecasts, but I haven't yet figured out why.

So my question is: when should I log-transform my time series before trying ARIMA methods on it?

/edit: after reading your answers, I'm going to use something like this, where x is my time series:

library(lmtest)
if ((gqtest(x~1)$p.value < 0.10) {
    x<-log(x)
}

Does this make sense?

$\endgroup$

4 Answers 4

23
$\begingroup$

Some caveats before to proceed. As I often suggest to my students, use auto.arima() things only as a first approximation to your final result or if you want to have parsimonious model when you check that your rival theory-based model do better.

Data

You have clearly to start from the description of time series data you are working with. In macro-econometrics you usually work with aggregated data, and geometric means (surprisingly) have more empirical evidence for macro time series data, probably because most of them decomposable into exponentially growing trend.

By the way Rob's suggestion "visually" works for time series with clear seasonal part, as slowly varying annual data is less clear for the increases in variation. Luckily exponentially growing trend is usually seen (if it seems to be linear, than no need for logs).

Model

If your analysis is based on some theory that states that some weighted geometric mean $Y(t) = X_1^{\alpha_1}(t)...X_k^{\alpha_k}(t)\varepsilon(t)$ more known as the multiplicative regression model is the one you have to work with. Then you usually move to a log-log regression model, that is linear in parameters and most of your variables, but some growth rates, are transformed.

In financial econometrics logs are a common thing due to the popularity of log-returns, because...

Log transformations have nice properties

In log-log regression model it is the interpretation of estimated parameter, say $\alpha_i$ as the elasticity of $Y(t)$ on $X_i(t)$.

In error-correction models we have an empirically stronger assumption that proportions are more stable (stationary) than the absolute differences.

In financial econometrics it is easy to aggregate the log-returns over time.

There are many other reasons not mentioned here.

Finally

Note that log-transformation is usually applied to non-negative (level) variables. If you observe the differences of two time series (net export, for instance) it is not even possible to take the log, you have either to search for original data in levels or assume the form of common trend that was subtracted.

[addition after edit] If you still want a statistical criterion for when to do log transformation a simple solution would be any test for heteroscedasticity. In the case of increasing variance I would recommend Goldfeld-Quandt Test or similar to it. In R it is located in library(lmtest) and is denoted by gqtest(y~1) function. Simply regress on intercept term if you don't have any regression model, y is your dependent variable.

$\endgroup$
3
  • $\begingroup$ thanks for the info. With the GQ test, the lower the p value, the more likely the distribution is heteroskedastic? $\endgroup$
    – Zach
    Jan 19, 2011 at 19:56
  • $\begingroup$ @Zach: exactly, take 5% for instance, of course if you are not planning to go for data mining. I personally start from the model assumptions. $\endgroup$ Jan 20, 2011 at 7:52
  • $\begingroup$ @Dmitrij. Thank you. I just want to make sure I'm interpreting the output correctly. $\endgroup$
    – Zach
    Jan 20, 2011 at 14:30
41
$\begingroup$

Plot a graph of the data against time. If it looks like the variation increases with the level of the series, take logs. Otherwise model the original data.

$\endgroup$
1
  • 5
    $\begingroup$ Here's a question: what is the effect if you take logs and they're not called for? I've liked it when working with time series that require a log transform, because (as I understand it) the coefficients are ratios and at small values nearly percentages. (E.g. exp (0.05) = 1.051.) $\endgroup$
    – Wayne
    Jan 18, 2011 at 13:20
5
$\begingroup$

By Their Fruits Ye Shall Know Them

The assumption (to be tested) is that the errors from the model have constant variance. Note this does not mean the errors from an assumed model. When you use a simple graphical analysis you are essentially assuming a linear model in time.

Thus if you have an inadequate model such as might be suggested by a casual plot of the data against time you may incorrectly conclude about the need for a power transform. Box and Jenkins did so with their Airline Data example. They did not not account for 3 unusual values in the most recent data thus they incorrectly concluded that there was higher variation in the residuals at the highest level of the series.

For more on this subject please see http://www.autobox.com/pdfs/vegas_ibf_09a.pdf

$\endgroup$
1
$\begingroup$

You might want to log-transform series when they are somehow naturally geometric or where the time value of an investment implies that you will be comparing to a minimal risk bond that has a positive return. This will make them more "linearizable", and therefore suitable for a simple differencing recurrence relationship.

$\endgroup$
3
  • 2
    $\begingroup$ Transformations are like drugs : Some are good for you and some aren't. If tou are not interested in testing statistical hypothesis then you can assume anything you like. Parameteric tests of hypothesis have assumptions about the error pricess, ignore them at your peril. $\endgroup$
    – IrishStat
    Jan 24, 2013 at 23:17
  • 1
    $\begingroup$ So true. I did say that the process needed to be geometric. Failing to transform can lead to errors in inference as well. I do not see where I was suggesting one ignore the assumptions regarding the conditions of valid inference. $\endgroup$
    – DWin
    Jan 25, 2013 at 0:08
  • 2
    $\begingroup$ stats.stackexchange.com/questions/6498/… included a discussion of when and why to transform. The "fact" that the original deries is "geometric" doesn't infer that the residuals from an adequate model have a standard deviation that is proportional to the mean. It could BUT it has to be empirically proven or at least tested. $\endgroup$
    – IrishStat
    Jan 25, 2013 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.