With the below dataset, I have a series which needs transforming. Easy enough. However, how do you decide which of the SQRT or LOG transformations is better? And how do you draw that conclusion?

y<-ts(x,frequency=12, start=c(1976,1))
#Transforming the data to log or sqrt and plotting it
  • $\begingroup$ Log if that's the choice. Behaviour looks much simpler on log scale, trend is more nearly linear and variability about constant. But a Poisson regression might do just as well without the transforming-back-transforming stuff so long as you think about serial dependence. That's heresy for those who incline to the view "time series require time series software, period". $\endgroup$
    – Nick Cox
    Commented Nov 4, 2013 at 13:48
  • $\begingroup$ @NickCox Solutions shouldn't be less than they should be or more than they should be. If you have time series data then the analysis (probably) requires time series software as simple solutions often lead to simply incorrect conclusions. Here I stand , I can do no other ... said a favorite heretic of mine. $\endgroup$
    – IrishStat
    Commented Nov 4, 2013 at 22:42
  • $\begingroup$ There are many examples of models fitted to data in time that are not time series models, e.g. growth models. At first blush this model looks well fitted by an exponential plus sinusoidal terms. If so, I would not push it into a Box-Jenkins-type ARIMA plus bells and whistles mode. Unfortunately, there is no substantive context in this question to guide recommendations. $\endgroup$
    – Nick Cox
    Commented Nov 4, 2013 at 23:47
  • $\begingroup$ @NickCox validation of the Gaussian assumptions are not bells and whistles but the underpining of the GLM. $\endgroup$
    – IrishStat
    Commented Nov 5, 2013 at 0:36
  • 1
    $\begingroup$ I am alluding to your extra machinery for "Level Shifts, Seasonal Pulses and/or Local Time Trends". $\endgroup$
    – Nick Cox
    Commented Nov 5, 2013 at 0:39

3 Answers 3


Transformations are like drugs ! Some are good for you and some aren't !. Haphazard selection of transformations should be studiously avoided.

a) One of the requirements in order to perform valid statistical tests of necessity is that the variance of the errors from the proposed model must not be proven to be non-constant. If the variance of the errors changes at discrete points in time then one has recourse to Generalized Least Squares or GLM .

b) If the variance of the errors is linearly relatable to the level of the observed series then a Logarithmic Transformation might be appropriate. If the square root of the variance of the errors is linearly relatable to the level of the original series then a Square Root transformation is appropriate. More generally the appropriate power transformation is found via the Box-Cox test where the optimal lambda is found. Note that the Box-Cox test is universally applicable and doesn't soley requite time series or spatail data.

All of the above ( a and b ) require that the mean of the errors cannot be proven to differ significantly from zero for all points. If your data is not time series or spatial in nature then the only anomaly you can detect is a pulse. However if your data is time series or spatial then Level Shifts , Seasonal Pulses and/or Local Time Trends might be suggested to render the mean value of the error term to be 0.0 everywhere or at least not significantly different from 0.0 .

In my opinion one should never willy-nilly transform the data unless one has to in order to satisfy (in part) the Gaussian assumptions. Some econometricians take logs for the simple and simply wrong reason in order to obtain direct estimates of elasticity's rather than assessing the % change in Y for a % change in x from the best model.

Now one caveat, if one knows from theory or at least one thinks that one knows from theory that transformations are necessary i.e. proven by previous well-documented research , then by all means follow that paradigm as it may prove to be more beneficial that the empirical procedures I have laid out here.

In closing use the original data, minimize any warping of the results by mindless transformations, test all assumptions and sleep well at night. Statisticians like Doctors should never do harm to their data/patients y providing drugs/transformations that have nasty and unwarranted side-effects.

Hope This Helps .

Data Analysis using time series techniques on time series data:

a plot enter image description here suggests a series that has structural change. The Chow Test yielded a signifciant break point enter image description here . enter image description here . Analysis of the modt recent 147 values starting at 1999/5 yielded enter image description here with a Residual Plot enter image description here with the following ACF enter image description here . The forecast plot is enter image description here . The final model is enter image description here with all parameters statistically significant and no unwarranted power transformations which often unfortunately lead to wildly explosive and unrealistic forecasts. Power transforms are justified whrn it is proven via a Box-Cox test that the variablility of the ERRORS is related to the expected value as detailed here. N.B. that the variability of the original series is not used but the variability of model errors.

enter image description here

  • $\begingroup$ Thanks for the great post @IrishStat went through your attached doc too, great info! $\endgroup$
    – digdeep
    Commented Nov 5, 2013 at 13:12
  • $\begingroup$ If I can help you with SAS I would be glad to. Please contact me at my email address available from info. $\endgroup$
    – IrishStat
    Commented Nov 5, 2013 at 15:46

This question is answered beautifully by means of a spread-versus-level plot: a cube root transformation will stabilize the spreads of the data, providing a useful basis for further exploration and analysis.

The data show a clear seasonality:



Take advantage of this by slicing the data into annual (or possibly biennial) groups. Within each group compute resistant descriptors of their typical value and their spread. Good choices are based on the 5-letter summary, consisting of the median (which splits the data into upper and lower halves), the medians of the two halves (the "hinges" or "fourths"), and the extremes. Because the extremes are not resistant to outliers, use the difference of the hinges to represent the spread. (This "fourth-spread" is the length of a box in a properly constructed box-and-whisker plot.)

spread <- function(x) {
  n <- length(x)
  n.med <- (n + 1)/2
  n.fourth <- (floor(n.med) + 1)/2
  y <- sort(x)[c(floor(n.fourth), ceiling(n.fourth), 
               floor(n+1 - n.fourth), ceiling(n+1 - n.fourth))]
  return( y %*% c(-1,-1,1,1)/2 )
years <- floor((1:length(x) - 1) / 12)
z <- split(x, years)
boxplot(z, names=(min(years):max(years))+1976, ylab="y")

Raw boxplots

The boxplots clearly get longer over time as the level of the data rises. This heteroscedasticity complicates analyses and interpretations. Often a power transformation can reduce or remove the heteroscedasticity altogether.

A spread versus level plot shows whether a power transformation (which includes the logarithm) will be helpful for stabilizing the spread within the groups and suggests an appropriate value for the power: it is directly related to the slope of the spread-vs.-level plot on log-log scales.

z.med <- unlist(lapply(z, median))
z.spread <- unlist(lapply(z, spread))
fit <- lm(log(z.spread) ~ log(z.med))
plot(log(z.med), log(z.spread), xlab="Log Level", ylab="Log Spread", 
     main="Spread vs. Level Plot")
abline(fit, lwd=2, col="Red")

Spread vs level plot

This plot shows good linearity and no large outliers, attesting to a fairly regular relationship between spread and level throughout the time period.

When the fitted slope is $p$, the power to use is $\lambda=1-p$. Upon applying the suggested power transformation, the spread is (approximately) constant regardless of the level (and therefore regardless of the year):

lambda <- 1 - coef(fit)[2]
boxplot(lapply(z, function(u) u^lambda), names=(min(years):max(years))+1976, 
        ylab=paste("y^", round(lambda, 2), sep=""),
        main="Boxplots of Re-expressed Values")

Boxplots of re-expressed values

plot(y^lambda, main= "Re-expressed Values", ylab=paste("y^", round(lambda, 2), sep=""))

Plot of re-expressed values

Often, powers that are reciprocals of small integers have useful or natural interpretations. Here, $\lambda = 0.32$ is so close to $1/3$ that it may as well be the cube root. In practice, one might choose to use the cube root, or perhaps round it to the even simpler fraction $1/2$ and take the square root, or sometimes go all the way to the logarithm (which corresponds to $\lambda = 0$).


In this example, the spread-versus-level plot (by virtue of its approximate linearity and lack of outliers) has shown that a power transformation will effectively stabilize the spread of the data and has automatically suggested the power to use. Although powers can be computed using various methods, none of the standard methods provides the insight or diagnostic power afforded by the spread-versus-level plot. This should be in the toolkit of every data analyst.


Tukey, John W. Exploratory Data Analysis. Addison-Wesley, 1977.

Hoaglin, David C., Frederick Mosteller, and John W. Tukey, Understanding Robust and Exploratory Data Analysis. John Wiley and Sons, 1983.

  • 4
    $\begingroup$ This is very nicely done as always. I would put a bit more emphasis on getting trend right first and a bit less on getting the handling of variability. That boosts the case for logarithms. No bias against cube roots, which feature in various papers of mine. $\endgroup$
    – Nick Cox
    Commented Nov 4, 2013 at 23:47
  • 2
    $\begingroup$ @whuber thanks for the detailed write up. Really helpful post and some neat R code too. $\endgroup$
    – digdeep
    Commented Nov 5, 2013 at 13:09
  • 1
    $\begingroup$ @Nick I agree that the trends (pre-2004 and post-2004 separately) are more linear for the logs. Some method to handle the heteroscedasticity would be essential for making forecasts: without that, forecasts based on the untransformed data would have optimistically narrow prediction intervals whereas forecasts based on logs would have pessimistically wide intervals. A short-term forecast may be robust to deviations from linearity--making cube roots a good first choice--but making longer-term forecasts does require close attention to the trend, initially favoring the log as you claim. $\endgroup$
    – whuber
    Commented Nov 5, 2013 at 18:27
  • $\begingroup$ @whuber I did power transformation on a ts and got -0.870478 as value of lambda (since slope > 1). After applying it, the trend is reversed - Is this (negative power and trend reversal) okay while stabilizing the variance? $\endgroup$ Commented Jul 22, 2020 at 14:10
  • 1
    $\begingroup$ @Stats It's ok, but one of the virtues of the Box-Cox transformation (instead of the straight power transformation) is that it does not reverse trends. The Box-Cox analog of your transformation is $x\to (x^{-0.87}-1)/(-0.87).$ Notice how the division by the (negative) power reverses the trend back again. See stats.stackexchange.com/a/467525/919 for more discussion. $\endgroup$
    – whuber
    Commented Jul 22, 2020 at 14:48

@digdeep, as usual @whuber provided an excellent and comprehensive answer from a statistical view point. I'm not trained in statistics, so take this response with a grain of salt. I have used the response below in my real world practice data, so I hope this is helpful.

I'll try to provide a non statistician view of transformation of time series data for Arima modeling. There is no straightforward answer. Since you are interested in knowing which transformation to use, it might be helpful to review why we do transformation.We do transformation for 3 main reasons and there might be ton of other reasons:

  1. Transformation makes the data's linear structure more usable for
    ARIMA modeling.
  2. If variance in the data is increasing or changing then transformation of data might be helpful to stabilize the variance in data.
  3. Transformation also makes the errors/residuals in ARIMA model normally distributed which is a requirement in ARIMA modeling proposed by Box-Jenkins.

There are several data transformations including Box-Cox, Log, square root, quartic and inverse and other transformations mentioned @irishstat. As with all the statistical methods there is no good guidance/answer on which transformation to select for a particular dataset.

As the famous statistician G.E.P Box said "All models are wrong but some are useful", this would apply to the transformations as well "All transformations are wrong but some are useful".

The best way to choose a transformation is to experiment. Since you have a long time series, I would hold out the last 12 - 24 months, and build a model using all the transformation and see if a particular transformation is helpful at predicting your out of sample data accurately. Also examine the residuals for normality assumption of your model. Hopefully, this would guide you in choosing an appropriate transformation. You might also want to compare this with non-transformed data and see if the transformation helped your model.

@whuber's excellent graphical representation of your data motivated me to explore this data graphically using a decomposition method. I might add, R has an excellent decomposition method called STL which would be helpful in identifying patterns that you would normally not notice. For a dataset like this, STL decomposition is helpful in not only selecting an appropriate method for analyzing your data, it might also be helpful in identifying anomalies such as outliers/level shift/change in seasonality etc., See below. Notice that the remainder (irregular) component of the data, looks like there is stochastic seasonality and the variation is not random, there appears to be a pattern. See also change in level of trend component after 2004/2005 that @whuber is refrencing.

Hopefully this is helpful.

g <- stl(y,s.window = "periodic")

enter image description here


Your Answer

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

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