1
$\begingroup$

I am having trouble explaining a recent finding to myself. I'm not sure if I'm asking a redundant question, but here is my situation:

1) Suppose I want to model the estimated probability of some outcome in a logistic model, then compare the estimated probabilities with a second set of estimated probabilities from a second logistic model. I'm doing this in R, and below is a "toy" example using the mtcars dataset. In this example, imagine that I want to summarise the average probability that a car has vs = 1 based on its carb:

library(tidyverse)

#Let's use a simple model

fit1 <- glm(vs ~ as.factor(carb), family = binomial(link = "logit"), data = mtcars)

I can compute the average probability for each level of carb as follows:

#Yes, I realize that all cars with a given carb will have the same estimate, so taking the mean is a bit pointless

cbind.data.frame(mtcars, pred = predict(fit1, type = "response")) %>% group_by(carb) %>% summarise(mean(pred)) # A tibble: 6 x 2 carb mean(pred) <dbl> <dbl> 1 1 1.000
2 2 0.500
3 3 0.00000000322 4 4 0.200
5 6 0.00000000318 6 8 0.00000000318

So far so good. These results are a bit weird, but whatever. (They are easy to interpret, at least) Now I want to fit a more complex model, incorporating a new predictor (mpg) that should help me get an estimate of the probability after adjusting for MPG.

fit2 <- glm(vs ~ as.factor(carb) + mpg, family = binomial(link = "logit"), data = mtcars)

cbind.data.frame(mtcars, pred = predict(fit2, type = "response")) %>% group_by(carb) %>% summarise(mean(pred))

# A tibble: 6 x 2 carb mean(pred) <dbl> <dbl> 1 1 1.000
2 2 0.500
3 3 0.00000000322 4 4 0.200
5 6 0.00000000318 6 8 0.00000000318

What I can't figure out is: why are the estimates exactly the same? Surely mpg must have some predictive value that assists our estimate. Can anyone help explain what is going on here?

$\endgroup$

1 Answer 1

1
$\begingroup$

To take an example, of the $10$ cars with $4$ carburetors, $2$ (both Mercedes) have their cylinders arranged straight (vs=1) and $8$ in a V (vs=0).

Your first model therefore predicts that each car with $4$ carburetors has a probability of $0.2$ of having cylinders arranged straight, and it obviously cannot do better than this

Your second model takes into account mpg to change the predictions for different cars and each car now has a different predicted probability, but it still gives the average probability of $0.2$ for cars with $4$ carburetors of having cylinders arranged straight, and this makes intuitive sense. Note that the predicted probabilities for the $2$ Mercedes $4$ carburetors with both rise, and the average for the non-Mercedes with $4$ carburetors fall, so in a sense these predictions are better

$\endgroup$

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.