Comparing logistic regression outputs
When building models, you want to have more observations than parameters that are estimated for the model. These extra variables are called degrees of freedom.
A model with too few observations can be overfit, or even be un-fitable (sometimes call singular). Furthermore, looking at the degrees for freedom can help you double-check your data and code. For example, a mismatch between the degrees of freedom and the number of observations you think you have can indicate that your data needs to be cleaned more, there is a bug in your code, or that there is a modeling error.
The wide versus long input formats for the glm()
produce different degrees of freedom because the difference in number of rows of the data causes the model to think that there is a difference in number of observations.
In the previous exercises, you fit a logistic regression using three different input options.
These have been loaded for you as lr_1
, lr_2
, and lr_3
.
Look at the summaries of these three models.
How do the degrees of freedom vary across the models?
This exercise is part of the course
Generalized Linear Models in R
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
