# The order of Data Centering and Data Transformation

Edit: I just read a related post (How to include $x$ and $x^2$ into regression, and whether to center them?) which mentions that centering a variable creates a new variable.

However, as the comments point out, taking the logarithm of negative values doesn't make sense (stupid me for not thinking this through) so I changed the first option.

I'm working with a multiple regression where log transforming a few of my predictors drastically improves the model assumptions. However, this improvement is for un-centered data and centered data on the mean would be much more interpretable.

I understand that centering data does not affect the distribution (it only shifts the mean), and would like to ask when I should center my data. Is there any general rule of thumb?

1] Do I center the predictor about its mean first and then search for a different transformation which improves model assumptions should they be violated?

2] Do I perform the log transformation first, then center by the mean of these log transformed values? How would this change model interpretation compared to option 1]?

• Thank you for the feed back Nick. I've edited my post in turn, and will read into $log(x+1)$. I did in fact hear of this from a biology mentor of mine in the past. Feb 11, 2015 at 9:55

If logarithms of predictors, generically $x$, are helpful, and centring variables on their mean is helpful, would it help to centre before transforming?

Once you have subtracted the mean from a variable, then necessarily at least one value is now negative and logarithms can't (usefully) be calculated (setting aside complex analysis).

Even if you discard the specific suggestion of $\log(x−$ mean of $x)$ on those grounds, the more general idea of transforming $(x−$ mean of $x)$ still

1. requires a transformation that will work with positive, zero and negative values; there are some (cube root, asinh, ...) but they won't usually help you in any situation in which logarithms are being contemplated seriously

2. implies that the mean of untransformed data is in some sense a natural or even a convenient origin for the transformed scale, which I think is usually not the case. So it's no go generally for your  in my view.

By all means, centre variables, transformed or not, in presenting regression results; it's the same regression and it's a matter of convenience how you explain it. So on your  I don't think it changes model interpretation at all; it's just convenience whether you write about centred results.

By the way, there is no "of course" about using $\log(x+1)$ even if $x \ge 0$. That's an ad hoc fudge that some people use, especially it seems in some branches of biology. But there is no standard or accepted logic to it.

This is not a question with a straightforward answer. There are deep issues involved.

If logarithm of a variable, say X, is improving the model, then X is an important variable itself as a "level". For example, stock prices are not important as levels (of course this is debatable), because they are recalculated after stock splits, whereas market capitalization of a company, or price of oil may be a level. That's why researchers are mostly using the price differences, or %changes (returns), of stock prices.

Another way of looking at it is to see whether the data generating process is stationary or not. If it is not, then mean centering is something very dubious as you expect the mean to be different for future unseen data points.

When level is not important and the variable is stationary, then you can mean center your variables. But I still personally don't like it. The reason is that when you are calculating the mean for each variable you are in fact estimating the mean. When you are estimating something it means there is an error (big or small). There are situations where the total error from estimating the means of several variables separately can be higher than when estimated together.

Then there is the concept of cointegration. Several variables may not be stationary individually but when combined in a certain way may yield a stationary signal. I don't know your data domain, but it seems to me your variable that you would like to log transform is important as a level, but the fact that you would like to mean center it tells me that there are other variables with a relative meaning to this variable. Maybe you have cointegrating variables.

• This seems to be based on the assumption that the question is about time series. That would be a different question, I think. Naturally you are at liberty to cast the net wider. But I think your misgiving is just personal queasiness: If you rewrite (say) $y = a + b x$ as $y - \bar y = b(x - \bar x)$, there is no estimation of means over and above what a regression does, already, regardless. It's just a question of parameterisation. Feb 11, 2015 at 12:25
• In the comment above, I am taking it as read that joint choice of transform and mean in transform($x -$ mean of $x$) is usually a bad idea. Feb 11, 2015 at 15:32
• @NickCox. I always see everything as time series, because we pretty much always observe and record data one by one. Each sample may or may not be IID. It is just an assumption of a plain vanilla regression. Nevertheless, my answer is tailored towards time series, that's true. Feb 11, 2015 at 19:04
• I understand, but it's not a universal point of view. I've found that economists (such as I guess you are) take the default view that everyone else is an economist using their kind of data unless it is obvious otherwise. As a geographer I tend to assume that everyone else is not a geographer unless it is obvious otherwise. Feb 11, 2015 at 19:18