2
$\begingroup$

I would like to compare the slopes of multiple logistic regressions, like an ANCOVA. Can a logistic regression even have a "slope" ? My regression lines themselves appear quite linear.

My dependent variable is binary (active vs. not active), while the independent variable is continuous, and there are multiple (6) levels to my categorical predictor. I would like to know how different these regression lines are from each other.

Right now I have separated my data into 6 logistic models, and I have a log odds ratio (instead of a slope) as my coefficient for each. For linear models, I can discuss a lot about the slopes of linear regression lines, along with R squared and p values, but I am unsure how to interpret the log odds ratio, other than converting it into a proportion (I've read other threads on CV).

Is there a way to do something like an ANCOVA for a multiple logistic regression? I am using R.

EDIT: Some additional information on my data and whole-model analysis attempt: I am using a generalized linear mixed effects model (glmer function in R) and so I have a random effect ("Pond") and I've nested individual "ID" to account for repeated measures. "Treat" represents the density levels. I have been getting various warning messages and I worry the output I get cannot be trusted, see below:

 m1 <- glmer(Act_01~Length*Treat+(1|Pond/ID), data=tad, family=binomial)

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 4 negative eigenvalues

 mcomp<- glht(m1, linfct=mcp(Treat="Tukey"))

Warning messages:
1: In mcp2matrix(model, linfct = linfct) :
  covariate interactions found -- default contrast might be inappropriate
2: In vcov.merMod(model) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
 summary(mcomp)

 Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Tukey Contrasts
Fit: glmer(formula = Act_01 ~ Length * Treat + (1 | Pond/ID), data = tad, 
    family = binomial)
Linear Hypotheses:

              Estimate Std. Error z value Pr(>|z|)    
A2 - A1 == 0    2.492      3.199   0.779  0.97105    
A3 - A1 == 0    6.704      3.265   2.053  0.31163    
A4 - A1 == 0    3.853      3.182   1.211  0.83142    
A5 - A1 == 0   -4.340      3.348  -1.296  0.78673    
A6 - A1 == 0   -6.516      3.269  -1.993  0.34535    
A3 - A2 == 0    4.212      3.037   1.387  0.73428    
A4 - A2 == 0    1.361      2.903   0.469  0.99718    
A5 - A2 == 0   -6.831      3.038  -2.248  0.21499    
A6 - A2 == 0   -9.008      3.024  -2.978  0.03423 *  
A4 - A3 == 0   -2.851      2.961  -0.963  0.92938    
A5 - A3 == 0  -11.044      3.210  -3.440  0.00766 **  
A6 - A3 == 0  -13.220      3.018  -4.381  < 0.001 ***    
A5 - A4 == 0   -8.193      3.066  -2.672  0.08062 .  
A6 - A4 == 0  -10.369      2.966  -3.496  0.00632 **      
A6 - A5 == 0   -2.176      3.181  -0.684  0.98369

Signif. codes:  0  ‘***’  0.001 ‘**’  0.01 ‘*’  0.05 ‘.’  0.1 ‘ ’  1
(Adjusted p values reported -- single-step method)****
$\endgroup$
  • 5
    $\begingroup$ Logistic regression is still a linear model and can of course have a slope. You can employ a similar strategy as I have outlined there. $\endgroup$ – Roland Dec 19 '16 at 7:03
  • 4
    $\begingroup$ Do not fit separate models, fit one to all the data with an interaction between your continuous and categorical predictors. $\endgroup$ – mdewey Dec 19 '16 at 13:40
  • $\begingroup$ Thank you for your comments. I have already attempted an analysis with the data in one model as @mdewey mentioned, however I get many warning messages (see my edit above). $\endgroup$ – Kat Y Dec 19 '16 at 20:34
  • 2
    $\begingroup$ Several comments: 1.) could you write out your regression equation so that those of us who are not R users can understand what it is you are trying to fit? For example: How many covariates does your model have? Do you have both a continuous and a categorical predictor, the latter with 6 levels? 2.) What was the reason for you to fit 6 separate logistic regression models? $\endgroup$ – Marquis de Carabas Dec 20 '16 at 22:01
  • $\begingroup$ Hello! 1) my regression equation is: Activity = Length * Treatment + (Pond|ID) The Pond term is the mixed effect component with nested ID, The Length term is continuous, the Treatment term is categorical with 6 levels. Activity is the [0,1] response variable 2) the reason to fit separate logistic regressions was originally to compare "slopes" of each Activty vs Length regression between each Treatment category. I have since used the ANCOVA to compare the slopes... $\endgroup$ – Kat Y Jan 12 '17 at 21:09
1
$\begingroup$

As mdewey notes, the best approach is to fit a single model with an interaction term to capture the group differences you are interested in.

It's difficult for readers to solve the issues raised by your warning messages without more information. But a common recommendation is to simplify your random effects structure till warnings stop, in order to understand what might be causing them.

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