# Scaling categorical data in regression

It seems odd to scale a categorical variable, but I need to get the correct coefficients for each of my variables in linear regression. Is it correct to scale the same way you would with continuous variables, or what is the right thing to do here?

For example if x is categorical and y is continuous:

model=lm(DV ~ scale(x) + scale(y), data=myData)


Is the above the right thing to do?

• What do you mean by "the correct coefficients"? Correct with respect to what standard? – Glen_b Sep 24 '14 at 10:12
• It's not correct to scale a factor variable for regression like that. – Roland Sep 24 '14 at 11:10
• From my understanding, if you don't scale, than the betas/coefficient values are not meaningful. It seems weird to only scale some variables (e.g. continuous variables) if you have both in an equation though. – Brandy Riedel Sep 24 '14 at 19:47
• I don't understand your understanding. If the scales of your variables are very different it is recommended to normalize them. Otherwise it's not necessary. However, a factor is dummy-encoded automatically by the lm function, i.e., each level (minus the reference level) is encoded as one dummy of 0/1 values. There is no need for scaling since all dummies are on the same scale. Using scale for a factor variable should throw an error. – Roland Sep 25 '14 at 9:28
• I was saying in my example that some predictors are categorical, but also some are continuous, so they would not all be on the same scale without some transformation. – Brandy Riedel Sep 25 '14 at 18:12