9

In case of a linear regression, it's easy to test a linear relationship between a continuous dependent variable and each independent variable. For example, I can plot a scatter plot between the dependent variable on Y-axis and one of independent variables on X-axis to visualize the relationship before using the linear regression.

But, a logistic regression is different, it assumes a linear relationship between log odds of a binary dependent variable and independent variables. I want to test this assumption to determine if the logistic regression is appropriate for my dataset. Can I test it? and How?

Besides, is there any package in R to do the task?

Cha.Po
  • 91
  • 4
  • In terms of packages in R, have a look at the gam() function of package mgcv which allows for non-linearity using smoothing splines. Then you can plot the resulting model using plot() to view that non-linearity on the log.odds scale – Lachlan Jul 03 '21 at 06:43

1 Answers1

1

Nice question. In practice, very few people pretest this assumption, or test it at all. To do so you could divide each independent variable (X) into perhaps 8 or 10 or 15 equal-interval categories. Then compute log-odds as ln(p/[1-p]) within each category, where p = the proportion of cases for which the dependent variable = 1 rather than 0. Finally, use ANOVA or, informally, view a scatterplot to assess the linearity of the relationship between log-odds and this X.

rolando2
  • 11,645
  • 1
  • 39
  • 60