Hypothesis testing for logistic regression with categorical predictor

I want to perform logistic regression in R, where one of my predictors, $$x_i$$ is categorical (takes on the values A, B, and C). A is the reference category. The model is set up as follows:

$$logit(P(Y_i = 1)) = \beta_0 + \beta_1I(x_i=B) + \beta_2I(x_i=C)$$

I want do a hypothesis test for whether the percentage chance of success is the same given $$x_i = A$$, $$x_i = B$$, or $$x_i = C$$. For example, to test if there is a significant difference in probability of success between $$x_i = A$$ and $$x_i = B$$, I can test the null hypothesis, $$H_0: \beta_1 = 0$$. To test if there is a significant difference in probability of success between $$x_i = A$$ and $$x_i = C$$, I can test the null hypothesis, $$H_0: \beta_2 = 0$$.

But how do I test whether there is a significant difference between $$x_i = B$$ and $$x_i = C$$? My confusion is that $$A$$ is the reference category, so I don't know how to directly test the hypothesis.

UPDATE: For the difference between B and C, would I be testing $$H_0: \beta_2 - \beta_3 = 0$$? And if so, how could this be done from the logistic regression output in R?

• @JimG i I think you misunderstand. The reference level is included in the intercept by default. Commented Aug 6, 2020 at 18:21
• @JimG I think you are missing the issue. For regression with categorical predictors, the predictors are turned into dummy variables (one for each level of the predictor), with one of the levels used by default as the reference level. I am still using $x_i=A$ in my logistic regression. Predictions for $x_i=A$ just correspond to the intercept, $\beta_0$.
– bob
Commented Aug 6, 2020 at 18:32
• Never mind. Thanks for the refresher. I was thinking in terms of multiple logistic regression
– user293277
Commented Aug 6, 2020 at 18:42

1 Answer

In R you can use glht (generalized linear hypothesis test) command in the multcomp package to define the contrasts of interest and test them, though I would advise against much reliance on p value "significance"

• Would $\beta_2 - \beta_3 = 0$ be the contrast of interest for testing a significant difference between $x_i=B$ and $x_i = C$?
– bob
Commented Aug 6, 2020 at 18:29
• Yes that's right. I would personally be more interested in the differences in estimates but if you seek p values that's one way to do it Commented Aug 6, 2020 at 18:32
• After using glht (thanks for that suggestion, btw), running summary(glht(model_object, c("varB = 0", "varC = 0"))), I'm seeing different p-values than those same variables have in the output of the logistic regression. That doesn't make sense to me?
– bob
Commented Aug 6, 2020 at 18:39
• For reference for anyone reading this, glht adjusts for multiple tests by default. This was the reason for the p-values not matching up. If you only do one contrast with each call to glht(), the corresponding values will match up with the original regression output.
– bob
Commented Aug 7, 2020 at 4:45
• @bob Ahh yes, that makes complete sense. I should have thought of that ! Commented Aug 7, 2020 at 5:01