18
$\begingroup$

I have a data set that contains both categorical variables and continuous variables. I was advised to transform the categorical variables as binary variables for each level (ie, A_level1:{0,1}, A_level2:{0,1}) - I think some have called this "dummy variables".

With that said, would it be misleading to then center and scale the entire data set with the new variables? It seems as if I would lose the "on/off" meaning of the variables.

If it is misleading, does that mean I should center and scale the continuous variables separately and then re-add it to my data set?

TIA.

$\endgroup$
1
  • 1
    $\begingroup$ Whether it is acceptable or reasonable to center and/or scale dummy variables depends on the application, on the analysis you are planning and task-specific considerations. So there is no single correct answer. In most general, rough formulation, it is often ok to do it with predictor dummy variables; it is often a bad idea to to it with response dummy variables or in multivariate methods such as clustering or factor analysis. $\endgroup$
    – ttnphns
    Aug 30, 2017 at 15:35

3 Answers 3

17
$\begingroup$

When constructing dummy variables for use in regression analyses, each category in a categorical variable except for one should get a binary variable. So you should have e.g. A_level2, A_level3 etc. One of the categories should not have a binary variable, and this category will serve as the reference category. If you don't omit one of the categories, your regression analyses won't run properly.

If you use SPSS or R, I don't think the scaling and centering of the entire data set will generally be a problem since those software packages often interprets variables with only two levels as factors, but it may depend on the specific statistical methods used. In any case, it makes no sense to scale and center binary (or categorical) variables so you should only center and scale continuous variables if you must do this.

$\endgroup$
2
  • 4
    $\begingroup$ My strong feeling is that the only part of the answer that is really answering the OP question is that last sentence - an that part being unexplained. You say don't scale them but don't explain why. Meanwhile, the topic is not very easy. $\endgroup$
    – ttnphns
    Sep 1, 2017 at 8:00
  • $\begingroup$ This is only one way of coding categorical variables. I don't have time to write a full answer, but searching on "contrasts" might help. A relevant answer is stats.stackexchange.com/questions/60817/… $\endgroup$
    – user20637
    Sep 13, 2018 at 18:21
5
$\begingroup$

If you are using R and scaling the dummy variables or variables having 0 or 1 to a scale between 0 and 1 only, then there won't be any change on the values of these variables, rest of the columns will be scaled.

maxs <- apply(data, 2, max) 
mins <- apply(data, 2, min)

data.scaled <- as.data.frame(scale(data, center = mins, scale = maxs - mins))
$\endgroup$
1
  • $\begingroup$ Interesting tip. Thank you for sharing. It's been awhile since I asked, but good to see I can still learn from these old posts. $\endgroup$ Aug 31, 2017 at 22:33
3
$\begingroup$

The point of mean centering in regression is to make the intercept more interpretable. That is, id you mean center all the variables in your regression model, then the intercept (called Constant in SPSS output) equals the overall grand mean for your outcome variable. Which can be convenient when interpreting the final model.

As to mean centering dummy variables, I just had a conversation with a professor of mine about mean centering dummy variables in a regression model (in my case a randomized block design multilevel model with 3 levels) and my take-away was that mean centering the dummy variables doesn't actually change the interpretation of the regression coefficients (except that the solution is completely standardized). Usually, it is not necessary in regression to interpret the actual unit level mean centered value - only the coefficients. And this essentially doesn't change - for the most part. She said it changes slightly because it's standardized which, for dummies, is not as intuitive to understand.

Caveat: That was my understanding when I left my professor's office. I could, of course, have got it wrong.

$\endgroup$

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.