0
$\begingroup$

I want to calculate the percentage of deviance explained for my glm model. I read in some comments that McFadden is the same as % of deviance explained only when the family is binoinal (and they would have the same interpretation). In all other cases, they are not the same thing, and McFadden is misused under DescTools package.

I got these conclusions after reading these questions:

Therefore, I came up with an example that reproduces this behaviour. First, I will fit a model with Gamma family:

> m2 <- glm(Sepal.Width ~ Species,
+           data = datasets::iris, 
+           family = Gamma(link = "log"))
> m0 <- glm(Sepal.Width ~ 1,
+           data = datasets::iris, 
+           family = Gamma(link = "log"))
> # Thinking as McFadden From UCLA
> DescTools::PseudoR2(m2, "McFadden")
McFadden 
 0.43286 
> 1-((logLik(m2))/logLik(m0))
'log Lik.' 0.43286 (df=4)
> # Thinking as %dev explained
> (deviance(m0)-deviance(m2))/deviance(m0)
[1] 0.39249
> 1-(deviance(m2)/summary(m2)$null.deviance)
[1] 0.39249
> (summary(m2)$null.deviance-deviance(m2))/summary(m2)$null.deviance
[1] 0.39249

In this case, there is a difference (which it is "small". On a data that I am working it McFadden is equal to .032 and %dev is .49). When I fit a binomial model, they match:

> m2 <- glm(vs ~ mpg,
+           data = mtcars, 
+           family = binomial)
> m0 <- glm(vs ~ 1,
+           data = mtcars, 
+           family = binomial)
> # Thinking as McFadden From UCLA
> DescTools::PseudoR2(m2, "McFadden")
McFadden 
 0.41785 
> 1-((logLik(m2))/logLik(m0))
'log Lik.' 0.41785 (df=2)
> # Thinking as %dev explained
> (deviance(m0)-deviance(m2))/deviance(m0)
[1] 0.41785
> 1-(deviance(m2)/summary(m2)$null.deviance)
[1] 0.41785
> (summary(m2)$null.deviance-deviance(m2))/summary(m2)$null.deviance
[1] 0.41785

My question is:

  • Have I calculated correctly those coefficients? These differences really exists?

  • Is McFadden only valid for binomial models?

  • Is the interpretation of both coefficients the same?

I came up with this question, because there was some debate about this where it was not the central question and someone could have not noted this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.