Download and extract these data on animals at an animal shelter in California.
Set up your coding environment.
What factors affect an animal being adopted?
We have to recode our response variable to 1
and 0
:
Call:
glm(formula = response ~ animal_type, family = binomial, data = animal_shelter)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.80673 0.04769 -16.917 < 2e-16 ***
animal_typecat 1.15353 0.05067 22.766 < 2e-16 ***
animal_typedog 1.77260 0.05286 33.531 < 2e-16 ***
animal_typeother 0.33478 0.06758 4.954 7.28e-07 ***
animal_typerabbit 1.95438 0.11282 17.322 < 2e-16 ***
animal_typewild -0.80701 0.08627 -9.354 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 40092 on 29497 degrees of freedom
Residual deviance: 37232 on 29492 degrees of freedom
AIC: 37244
Number of Fisher Scoring iterations: 4
We have to calculate the \(R^2\) manually:
We can also get the effects: