One of the tricky parts about dummy coded (0/1) variables is keeping track of what’s a 0 and what’s a 1.

This is made particularly tricky because *sometimes your software switches them on you*.

Here’s one example in a question I received recently. The context was a Linear Mixed Model, but this can happen in other procedures as well.

I dummy code my categorical variables “0” or “1” but for some reason in the fixed effects table the variable with code “0” has a coefficient and the variable coded “1” has the coefficient “0” and and considered redundant. I always thought that the fixed effects table is similar to a regression table in that you should be able to calculate the estimates because you are given coefficients. but how can i do this when the dummy variables coded with a “0” have a coefficient and those coded “1” don’t. when i use the equation, won’t this variable always be zero.???

This person is rightfully confused. There’s no indication of what software was involved, but I’ve seen it happen in different software packages and in different procedures.

In SAS proc glm, when you specify a predictor as categorical in the CLASS statement, it will automatically dummy code it for you in the parameter estimates table (the regression coefficients). The default reference category–what GLM will code as 0–is the highest value. This works just fine if your values are coded 1, 2, and 3. But if you’ve dummy coded them already, it’s switching them on you.

Likewise, in both SPSS mixed and GLM, the default is to make the one that comes last alphabetically the reference group, 0. So if your data are M and F, M will be the reference group. But if the data are 0 and 1, 1 comes after 0 alphabetically, and 1 becomes the reference group. The new 0.

You may therefore be tempted to just put it in as a covariate–i.e., don’t tell your software it’s categorical. This usually works, but neither package will then give you means (lsmeans in SAS and EMMeans in SPSS) for that variable. Since interpreteing means is often much, much more intuitive, you have to define it as categorical.

You have to be careful in logistic regression as well. In binary logistic regression, the outcome variable is coded 0/1.

Not too long ago I made a big mistake working on a client’s data set, which luckily I caught when the results didn’t make sense.

The default in SPSS binary logistic regression is to model the odds that Y=1. I knew that, and assumed it was the same in GEE. Not so. So the model wasn’t wrong, per se. But I was interpreting everything backwards. Funny, none of the hypotheses were supported when the analysis was backward.

The lesson I learned? * Know thy software defaults. *

There are a lot of them. That’s one reason I say it really doesn’t generally matter much which stat software you use, as long as the one you’re using can do what you need.

**But whatever you choose, know it really, really well.**

Make the syntax manual your best friend in crime data analysis.

[For the record, I also recommend all researchers be able to use at least two stat software packages. Follow that link, if you’re wondering why].

If you want to learn more about interpreting coefficients, in one of my first webinars I literally went through the output of a model with both categorical and continuous predictors (and an interaction), and we went step-by-step through how to read the coefficients.

You can download it here: Interpreting Linear Regression Coefficients: A Walk Through Output. It’s free.<https://www.theanalysisfactor.com/interpreting-linear-regression-parameters-a-walk-through-output/” rel=”nofollow”>

{ 2 comments… read them below or add one }

Can you show with an example how to put this variable in the equation?

Hi

Thank you for sharing your knowledge. The article was very helpful for me. I have another question which is related to the next step, Interpreting and writing the regression equation from outputs. As you know, software will determine the estimations for each variables. If we have a categorical variable (for example with 4 levels ), we’ll have three coefficients (one level will be considered as a reference level). How should we write the regression equation? is there a way to merge the coefficients related to each levels of categorical variable??

{ 1 trackback }