I have a data set with 3 continuous variables and 3 categorical variables. I know that I have to create dummy variables for categorical variables but I am wondering if it is a must to do that for all 3 categorical variables in this case?
-
3$\begingroup$ If you want to include all the 3 categorical variables in your model, then yes. $\endgroup$– boscovichCommented Apr 7, 2012 at 17:36
-
$\begingroup$ This short article by Jon Starkweather gives an extensive explanation on the ways of including categorical variables in multiple regression. It should help you understand how to use categorical variables depending on your case and how to interpret the results. I recommend it because I myself found it very helpful when faced similar questions. $\endgroup$– Marta KarasCommented Feb 25, 2016 at 20:11
2 Answers
One advantage (out of many) of using R is that it takes care of this problem for you -- no need to assign dummies (just make sure the categorical variables are entered as strings instead of numbers).
Some basics: Multiple regression in R
-
$\begingroup$ Hi! thanks for the reply. Do you mean that I can just run a regression model using those categorical variables without dummies? Sorry I am still kinda new to stats! $\endgroup$– DarylCommented Apr 7, 2012 at 17:45
-
$\begingroup$ @Daryl that's definitely what I mean! With R, the problem of assigning dummy variables is taken care of for you! $\endgroup$– JulieCommented Apr 7, 2012 at 18:33
R does this for you, as @Julie said. But so do SAS and SPSS (and probably all other major stats packages).
Be careful, though, as different packages have different defaults for the way they code categorical variables. In R, see this document dummy coding is the default in lm() for unordered factors; the same is true in SAS PROC GLM, but unfortunately, PROC LOGISTIC uses effect coding by default.