0
$\begingroup$

So I started off with a model which included both continuous and categorical predictor variables. But now I wanted to drop the only continuous variable (distance to shore), because to my opinion it was too much correlated with other variables (habitattype). So that leaves me with only categorical predictors and there interaction terms in the model, but is that actually allowed for binomial regression?

If so, what is a good way to visualize the results? The predicted values over a predictor (categorical) is going to give strange graphs because of the limited categories.

$\endgroup$
2
$\begingroup$

Yeah, it's perfectly acceptable for a logistic regression to contain only categorical predictors. Remember that we code categorical predictors numerically (e.g., 0 and 1, -1 and 1, etc.), so the distinction between categorical and continuous doesn't really exist for the regression.

As for how to plot the effect, I would typically use a bar plot with each bar representing the estimated probability of observing a specific outcome in that condition. These estimates can be calculated using the coefficients of the model. Remember that while a logistic regression produces estimates in logit space, with an inverse logit transformation you can turn predicted values into probabilities.

The below graph actually plots the proportions (so what was observed in the data that was subsequently analysed with a logistic regression, rather than what was estimated by the regression), but it should convey the general idea.

enter image description here

$\endgroup$
  • $\begingroup$ Thank you for the clear answer! But almost all of my categorical variables have more than two levels (not 0 and 1) and one of them has Yes/No. So how does it work then? $\endgroup$ – Guido167 Jul 22 '16 at 9:01
  • $\begingroup$ Do you mean how does it work in the logistic regression, or how does it work for graphing? If the latter, add more bars. If the former, while you may have assigned the labels "yes" and "no" to the variable, the regression just sees it as a 0 and a 1. Similarly, your 3+ level categorical variables will be represented as 2+ numeric ones. See here $\endgroup$ – Ian_Fin Jul 22 '16 at 9:05
  • 1
    $\begingroup$ I'd suggest that you may want to familiarise yourself with how coding works for categorical variables. Different ways of coding variables means different meanings for your coefficients. You want to be sure that you're not misinterpreting the results. $\endgroup$ – Ian_Fin Jul 22 '16 at 9:07
  • $\begingroup$ Thank you @Ian_Fin! One more question, I also want to run a negative binomial on the same variables, but with a count response. Is that also allowed? $\endgroup$ – Guido167 Jul 22 '16 at 9:35
  • 1
    $\begingroup$ If you're asking is it okay to only have categorical predictors in a negative binomial regression then the answer is yes, for the same reasons as the logistic regression. If your question is different you may want to start a new question though - I know little about the intricacies of negative binomial models. $\endgroup$ – Ian_Fin Jul 22 '16 at 9:37
1
$\begingroup$

It certainly is allowed. I would suggest you choose a new approach to visualizing your data, other than the sigmoid curve. As you said being categorical means you do not have a range of data to assess your probability over. Categorical variables are either there or not. One approach that comes to my mind, is to plot circles or squares whose size is proportional to your category's parameter (the $\beta$ or $\theta$). I.e in case of gender, 1 female, 0 male, then your $\beta_{female}$ might be say 0.5. Then print a circle whose radius is 0.5, and you can compare other features' importance in predicting your class. Alternatively you can use a pie chart, again to show importance. Using squares has the benefit that you can show the marginal rate of substitution too. Assume you have the following data:

      gender_female   likes_plum   likes_peach   label

1           1              1            0          1

2           1              0            0          0

3           0              0            1          1

...

Then after your regression, you might have: $\beta_{female}=0.5,\beta_{plum}=1.4, \beta_{peach}=1$. Then if you draw squares whose sides are equal to the $\beta$s you can show how many of each $\beta$ fits in the other, effectively showing their relative importance. I.e. for our example being a peach lover has double the effect of being a female in being classified as class 1.

$\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.