I am developing a regression model and most of my variables are 0/1 variables.
Should these variables be treated as factor variables in the model or can they just be left as numeric 0,1?
In linear regression, if they are independent variables and 1 and 0 are the only possible outcomes, then either way is fine.
Modeled as binary, but specified it as if it's continuous (data and syntax are of Stata 12):
Modeled as factors:
It's worth noticing that if modeled as a continuous variable (though bear in mind it's actually binary), the reference group is always whatever coded as 0. In some statistical software, however, binary variables modeled as factors may have its reference group swapped to whatever = 1. The ANOVA and F statistics will not be affected but the regression coefficients can change (due to reference group being reassigned.) Check the output carefully.
In R, it doesn't matter if they are factors or numeric variables. But be sure to indicate that you're doing a logistic regression by indicating
Without indicating this, the assumed variance of the distribution will differ. In a binomial family, the variance (dispersion parameter) is taken to be 1, unlike in gaussian family.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?