Is it appropriate to do a logistic regression where both the dependent and independent variables are binary? for example the dependent variable is 0 and 1 and the predictors are contrast coded variables -1 and 1 ?
4 Answers
There is no reason not to do this, but two cautionary thoughts:
Keep careful track during the analysis of which is which. In large projects, it can be easy to get lost, and produce errant results.
If you choose to report regression estimates, rather than odds ratios, make your coding scheme clear in your report, so readers don't produce inaccurate ORs on their own assuming they were both coded 0,1.
May seem basic, but I've seen both problems make it into published papers.
-
$\begingroup$ So then it would also be appropriate to separate a datafile into 6 separate cases and run individual comparisons within each dataset with constrast coded predictors? $\endgroup$– upaboveCommented Aug 23, 2011 at 18:13
-
$\begingroup$ I'm honestly not sure what you're asking for this second bit. Can you clairify what you're hoping to accomplish? $\endgroup$– FomiteCommented Aug 23, 2011 at 19:28
-
$\begingroup$ I have a dataset with 3 between and 4 within subject conditions. I would like to test for each and every effect, but a single regression with all interactions miss a lot of information I'm interested in. Instead I would divide the data by condition into separate datasets and run focused logistic regressions on each datasets with contrast codes coding for the differences i'm interested in. $\endgroup$– upaboveCommented Aug 23, 2011 at 21:37
-
$\begingroup$ for even more info on how I code the contrast codes see here: stats.stackexchange.com/questions/14546/… $\endgroup$– upaboveCommented Aug 23, 2011 at 21:38
For, clarity: the term "binary" is usually reserved to 1 vs 0 coding only. More general word suitable for any 2-value coding is "dichotomous". Dichotomous predictors are of course welcome to logistic regression, like to linear regression, and, because they have only 2 values, it makes no difference whether to input them as factors or as covariates.
Typically it helps interpretation if you code your predictors 0-1, but apart from that (and noting that it is not required), there is nothing wrong with this. There are some other (contingency-table based) approaches, but if I recall correctly, these turn out to be equivalent to (some form of) logistic regression.
So in short: I see no reason not to do this.
-
$\begingroup$ thanks! And if I have 3 contrast coded predictors and I code them all 0-1 then they won't be orthogonal. For example I have 4 categories and my three codes are L1: 1,-1,0,0 L2: 0,1,-1,0, L3:0,0,1,-1. is that an issue? $\endgroup$– upaboveCommented Aug 22, 2011 at 9:46
-
$\begingroup$ Your example L-matrix (L1,L2,L3) is the repeated contrasts whereby each category is compared to the following category. Neither these contrast predictors are orthogonal nor they are binary (coded as 0-1). In fact, their values are .75 vs -.25 (1st variable), .5 vs -.5 (2nd variable), .25 vs -.75 (3rd variable) $\endgroup$– ttnphnsCommented Aug 22, 2011 at 10:13
In addition, if you have more than two predictors, then it is more likely that there would be a problem of multi-collinearity even for logistic or multiple regression. However, there is no harm to use logistic regression with all binary variables (i.e., coded (0,1)).