# When to log transform a time series before fitting an ARIMA model

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? - ## 4 Answers 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.

-
+1, nice write-up –  mpiktas Jan 18 '11 at 18:53
thanks for the info. With the GQ test, the lower the p value, the more likely the distribution is heteroskedastic? –  Zach Jan 19 '11 at 19:56
@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. –  Dmitrij Celov Jan 20 '11 at 7:52
@Dmitrij. Thank you. I just want to make sure I'm interpreting the output correctly. –  Zach Jan 20 '11 at 14:30

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.

-
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.) –  Wayne Jan 18 '11 at 13:20

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 do in 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

-

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.

-
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. –  IrishStat Jan 24 '13 at 23:17
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. –  DWin Jan 25 '13 at 0:08
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. –  IrishStat Jan 25 '13 at 11:34