O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pseudo R-square

Recall that a true R-square measure is not a standard output statistic for logistic regression but there are other goodness of fit measures we can use, such as the McFadden pseudo R-square.

We calculate this in code, by first obtaining both the residual deviance and the null deviance. The residual deviance measures the deviation in the model with all of the dependent variables included. The null deviation measures the residuals with only the intercepts included. You want the ratio of deviation/null.devation to be as small as possible for a good model. Subtract this value from 1 to obtain a pseudo R-square.

All of these measures are available via the model_summary object:

#mcfadden pseudo Rsquare 1-(model_summary$deviance/model_summary$null.deviance) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required