6
$\begingroup$

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?

$\endgroup$
3
  • 4
    $\begingroup$ @JimG i I think you misunderstand. The reference level is included in the intercept by default. $\endgroup$ Aug 6, 2020 at 18:21
  • $\begingroup$ @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$. $\endgroup$
    – bob
    Aug 6, 2020 at 18:32
  • $\begingroup$ Never mind. Thanks for the refresher. I was thinking in terms of multiple logistic regression $\endgroup$
    – user293277
    Aug 6, 2020 at 18:42

1 Answer 1

5
$\begingroup$

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"

$\endgroup$
5
  • $\begingroup$ Would $\beta_2 - \beta_3 = 0$ be the contrast of interest for testing a significant difference between $x_i=B$ and $x_i = C$? $\endgroup$
    – bob
    Aug 6, 2020 at 18:29
  • $\begingroup$ 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 $\endgroup$ Aug 6, 2020 at 18:32
  • $\begingroup$ 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? $\endgroup$
    – bob
    Aug 6, 2020 at 18:39
  • 1
    $\begingroup$ 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. $\endgroup$
    – bob
    Aug 7, 2020 at 4:45
  • $\begingroup$ @bob Ahh yes, that makes complete sense. I should have thought of that ! $\endgroup$ Aug 7, 2020 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.