I am currently learning how to do statistical modelling in R and realised that if the response variable is dichotomous, it is better to go for logistic modelling as compared to linear modelling.

I used the run17 dataset from the cherryblossom package in R. The run17 dataset contains details for all 19,961 runners in the 2017 Cherry Blossom Run, which is an annual road race that takes place in Washington, DC. The dataset has an event column which denotes whether the participant ran in the "10 Mile" event or the "5 Km" event. I was interested to see if participants' event choice selection was affected by their age and sex. Since the event variable is dichotomous, I first converted it to boolean values (1 = 10 Mile event and 0 = 5 Km event) for it to work with the formula.

As the response variable is dichotomous, I used logistic modelling. But at the same, I also tried linear modelling to see what is difference between them. Given below is the code I used.

# Loading the required packages
if (!require(cherryblossom)) install.packages('cherryblossom')

# Converting event variable values into boolean 
run17_boolean <- run17
run17_boolean$event <- recode(run17_boolean$event, "10 Mile" = 1, "5K" = 0)

# Building the linear model
model_lm <- lm(event ~ sex + age, data = run17_boolean)

# Building the logistic model
model_glm <- glm(event ~ sex + age, data = run17_boolean, family = "binomial")

# Summary of the model

I find that the summary of the models is almost the same. I am still learning how to interpret the model summaries so I may be wrong here. I then tried to plot the model using ggplot2 to see if they are visually similar.


# Linear model
run17_boolean %>% ggplot(aes(age, event, col = sex)) +
  stat_smooth(method = "lm") +
  labs(x = "Age",
       y = "Event",
       title = "Event ~ Age + Sex (linear model)") + 

# Logistic model
run17_boolean %>% ggplot(aes(age, event, col = sex)) +
  stat_smooth(method = "glm", method.args = list(family = "binomial")) +
  labs(x = "Age",
       y = "Event",
       title = "Event ~ Age + Sex (logistic model)") + 

enter image description here

The graphs are also very similar as the fitted values are very similar between the plots.

  1. My question is why when linear modelling, which works best for continuous data gave very close results to logistic modelling even when I had a dichotomous response variable?

  2. Or is it just a chance that I got very similar results when lm() and glm() was used for this particular data and would not work for other datasets?

  • 2
    $\begingroup$ Welcome to CrossValidated, and thank you for a very nice and well-crafted question! $\endgroup$ Aug 1, 2022 at 6:49
  • $\begingroup$ Thank you! @StephanKolassa $\endgroup$
    – bukkad
    Aug 1, 2022 at 7:44

2 Answers 2


You have quite a lot of data, and very well-behaved data. In such a case, it does happen that the model fits from an ordinary and a logistic regression are close to each other, especially in the "middle" part of fitted probabilities, as are the p-values for the coefficients.

Note, though, that there are differences. The fitted probability as a function of Age is noticeably curved for sex = F in the logistic model, but linear in the OLS model (not surprising, of course, because of the log link). And the confidence region for sex = M at high Ages exceeds 1 in the OLS, which is of course nonsensical.

The key issue is that nonsensical fits (or predictions, or extrapolations) larger than 1 or smaller than 0 can easily happen in OLS models if you have less well-behaved data, for instance if you have lots of 1s in the dependent variable for certain parameter constellations. This can happen more easily, and be harder to detect, in more complex models with more than two parameters.

  • $\begingroup$ I never noticed the confidence intervals and yes now it makes more sense $\endgroup$
    – bukkad
    Aug 21, 2022 at 10:51

why when linear modelling, which works best for continuous data gave very close results to logistic modelling even when I had a dichotomous response variable?

The logistic curve can be approximated with a linear function for a small range. See in the image below a plot of the logistic curve and how in a small range (in the shaded area) the logistic curve is approximately linear.

example of linear approximation

The effect is true for any non-linear function (not just with logistic curves). When the range is very small, and non-linear functions start to be approximately linear, then many different functions can fit the same data reasonably well.

A similar situation is this question (Coronavirus growth rate and its possibly spurious resemblance to vapor pressure model) where data follows an approximately exponential model in a small range and many different models were found to fit the data well (among them an unreasonable fit with a vapour pressure model that has no physical relation with the mechanics of the original problem).

Or here Why would you perform transformations over polynomial regression?

multiple fits

  • 2
    $\begingroup$ Besides the excellent range issue, I'd expect agreement to wane as more variables appear in the model, as in that case linear models have greater difficulty in keeping predictions legally in [0,1]. $\endgroup$ Aug 17, 2022 at 11:28
  • $\begingroup$ @FrankHarrell I am not sure whether this depends intrinsically on the multidimensionality. I imagine that it is more indirectly and because multidimensional problems are often problems with a larger variation in the range. In the end, the non-linear part of the multidimensional logistic regression is effectively reduced to a one-dimensional problem by using a linear predictor $\eta = \boldsymbol{\beta} \mathbf{x}$ and the non-linear part of the function is one dimensional $$y = \frac{1}{1+\exp(-\boldsymbol{\beta} \mathbf{x})} = \frac{1}{1+\exp(-\eta)}$$ $\endgroup$ Aug 17, 2022 at 11:41
  • $\begingroup$ It could be that due to multidimensionality the range of the parameter $\eta$ becomes larger, as a sort of piranha effect some cases might have a very large or a very low value of $\eta$. Then, indeed, even though the range of $y$ is small, the range of the predictions $\hat{y}$ might be large. So it is more about the range of the predictors than the range of the outcome variable and in the multidimensional case this range increases. $\endgroup$ Aug 17, 2022 at 11:46
  • 1
    $\begingroup$ Yes. Put another way, the more predictors, the more interactions you need to add to the model to keep linear model estimates realistic (not far outside [0,1]). $\endgroup$ Aug 17, 2022 at 13:07

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.