4
$\begingroup$

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?

$\endgroup$
7
  • 4
    $\begingroup$ What do you mean by "the correct coefficients"? Correct with respect to what standard? $\endgroup$ – Glen_b Sep 24 '14 at 10:12
  • 1
    $\begingroup$ It's not correct to scale a factor variable for regression like that. $\endgroup$ – Roland Sep 24 '14 at 11:10
  • $\begingroup$ 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. $\endgroup$ – Brandy Riedel Sep 24 '14 at 19:47
  • 5
    $\begingroup$ 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. $\endgroup$ – Roland Sep 25 '14 at 9:28
  • $\begingroup$ 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. $\endgroup$ – Brandy Riedel Sep 25 '14 at 18:12
2
$\begingroup$

In a comment you write:

From my understanding, if you don't scale, than the betas/coefficient values are not meaningful.

this is not correct. They have meaning, it's just a different meaning. If you use the original units, then the coefficients are about the original units. Often, this is what yo want. If you scale, then the coefficients are about the scaled units - often standard deviation - sometimes this is what you want. Opinions differ as to how often to scale, how good it is to scale and so on.

Scaling a categorical variable doesn't really make much sense. It's not even clear what it would be. Categorical variables have to be parameterized, often by dummy coding (although other schemes are possible).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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