17
$\begingroup$

I have a numeric variable which turns out not significant in a multivariate logistic regression model. However, when I categorize it into groups, suddenly it becomes significant. This is very counter-intuitive to me: when categorizing a variable, we give some information up.

How can this be?

$\endgroup$
25
$\begingroup$

One possible explanation would be nonlinearities in the relationship between your outcome and the predictor.

Here is a little example. We use a predictor that is uniform on $[-1,1]$. The outcome, however, does not linearly depend on the predictor, but on the square of the predictor: TRUE is more likely for both $x\approx-1$ and $x\approx 1$, but less likely for $x\approx 0$. In this case, a linear model will come up insignificant, but cutting the predictor into intervals makes it significant.

> set.seed(1)
> nn <- 1e3
> xx <- runif(nn,-1,1)
> yy <- runif(nn)<1/(1+exp(-xx^2))
> 
> library(lmtest)
> 
> model_0 <- glm(yy~1,family="binomial")
> model_1 <- glm(yy~xx,family="binomial")
> lrtest(model_1,model_0)
Likelihood ratio test

Model 1: yy ~ xx
Model 2: yy ~ 1
  #Df  LogLik Df  Chisq Pr(>Chisq)
1   2 -676.72                     
2   1 -677.22 -1 0.9914     0.3194
> 
> xx_cut <- cut(xx,c(-1,-0.3,0.3,1))
> model_2 <- glm(yy~xx_cut,family="binomial")
> lrtest(model_2,model_0)
Likelihood ratio test

Model 1: yy ~ xx_cut
Model 2: yy ~ 1
  #Df  LogLik Df  Chisq Pr(>Chisq)  
1   3 -673.65                       
2   1 -677.22 -2 7.1362    0.02821 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

However, this does not mean that discretizing the predictor is the best approach. (It almost never is.) Much better to model the nonlinearity using or similar.

$\endgroup$
  • $\begingroup$ Are there some examples where discretizing might be sensible? For example, if you have a specific threshold (e.g. age 18) at which a binary switch in outcomes occurs. Numeric age in the 18+ range might not be significant, but binary age >18 might be significant? $\endgroup$ – ajrwhite Mar 19 at 18:40
  • 3
    $\begingroup$ @ajrwhite: it depends on the field. Anywhere that thresholds are codified in law discretization might make sense. E.g., if you model voting behavior, it makes sense to check whether someone is actually eligible to vote at age 18. Similarly, in Germany, your vehicle tax depends on your engine displacement and jumps at 1700, 1800, 1900, ... ccm, so pretty much all cars have displacements of 1699, 1799, ... ccm (kind of self-discretizing). In the natural sciences like biology, medicine, psychology etc., I struggle to find an example where discretization makes sense. $\endgroup$ – Stephan Kolassa Mar 20 at 6:03
7
$\begingroup$

One possible way is if the relationship is distinctly nonlinear. It's not possible to tell (given the lack of detail) whether this really explains what's going on.

You can check for yourself. First, you could do an added variable plot for the variable as itself, and you could also plot the fitted effects in the factor-version of the model. If the explanation is right, both should see a distinctly nonlinear pattern.

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