# Mean centering - before regression or observations that enter regression?

I am using Stata 13 to estimate a simple model with interaction terms. To give the coefficients a meaningful interpretation at zero, and to avoid multicollinearity, I am mean centering variables.

I am wondering when to do this. I.e. before estimating a regression or only for values that enter the regression? The question stems from the missing structure of my data. Because the mean of the centered variable is not zero when calculated for the observations that acctually entered the regession.

Maybe an example helps in making the point:

clear
set more off

sysuse auto.dta

*Randomly replace weight with missings
gen tomis = ceil(10*runiform())
replace weight=. if tomis==1

*Center mpg
sum mpg, meanonly
gen cmpg = mpg-r(mean)

*Regression
qui reg price cmpg weight foreign
qui gen sample = 1 if e(sample)

*Center mpg when in sample
sum mpg if sample==1, meanonly
gen cmpgs= mpg-r(mean)

*Sums
sum mpg cmpg cmpgs
sum mpg cmpg cmpgs if sample==1


In the example above I mean center mpg to cmpg. The mean of cmpg is thus (close to) zero. However the mean of cmpg is 0.278 for all observations that entered the regression. Does that make sense or should I center based on the observation that enter the regression as I do when generated cmpgs?

The p-value of the two versions of cmpg will be the same, and whether it's pre- or post-regression centering is only a matter of your choice. Really, you don't need any poll to make a decision, as long as you explain it clearly in the Methods section you're all set.

Practically, I would slightly favor centering the variables with cases that will be in the model (aka after list-wise deletion.) The reason is that it's a lot more natural to read:

Cases with missing values were excluded in this analysis. Continuous independent variables were then centered at mean before the regression analysis.

than:

Continuous independent variables were centered at mean. Cases with missing values were excluded from the analysis.

Both will give the same slope and p-value for cmpg, but the second one is more likely to cause confusion for people who understand enough about this technique but not enough to realize the two methods are nearly the same.

However, given the missing structure in my data I hardly know if the sample is in any way representative.

Not knowing the nature of missing is actually a much bigger issue here although it's not the focus of the question. Lacking this knowledge or even assumption can undermine possible understanding of potentially very large biases.

• Thanks, that helps me a great deal! I know the missing structure to be a great issue in this case. I am using a large scale panel and numerous authors accounted this very same problem with the data. – Rachel Jun 1 '15 at 12:46

As explained at When conducting multiple regression, when should you center your predictor variables & when should you standardize them?, centring doesn't substantively change your model, & it doesn't help with multicollinearity (see Is centering a valid solution for multicollinearity?). Whether centring around a predictor's mean before or after excluding some observations is more "meaningful" is entirely up to you. Still, unless the sample's representative of a population of interest (i.e. in the distribution of the predictors), it's hard to argue that the mean before excluding some observations is at all special.

• Good point. However, given the missing structure in my data I hardly know if the sample is in any way representative. My gut feeling tells me to mean center based on the observation entering the regression. But I could argue either way. Given the example above, what would you do? (I know centering makes no sense whatsoever in the example above, I merely am pointing out the mechanics). – Rachel Jun 1 '15 at 12:13
• I wouldn't centre, though I might pick a value of mpg I thought more suitable as a reference than zero if I thought it would aid interpretation of the model coefficients. – Scortchi - Reinstate Monica Jun 1 '15 at 12:26
• In my case I am analyzing input data and their effect on output data. So centering would allow the intepretation at "mean input". So I figured it is appropiate here. – Rachel Jun 1 '15 at 12:29
• If you could explain exactly why that interpretation's helpful you could answer your own question. – Scortchi - Reinstate Monica Jun 1 '15 at 13:00

Instead of making the model harder to interpret by the use of centering, and having to remember the centering constants whenever you want to get a prediction from the model, I always model the original data and avoid making hypothesis tests on quantities arbitrarily affected by the variables' origins. In short, centering is not worth the effort. However some of my R functions secretly center and scale variables behind the scenes to avoid some numerical problems when analyzing massive datasets. The final results are restated in terms of the original variable coding automatically so the analyst doesn't see what's going on.