Perform the following steps to fit a generalized linear regression model with the Binomial model:
- First, we examine the first six elements of vs within mtcars:
> head(mtcars$vs) Output: [1] 0 0 1 1 0 1
- We apply the glm function with binomial as the family object:
> lm1 = glm(vs ~ hp+mpg+gear,data=mtcars, family=binomial)
> summary(lm1)
Output:
Call:
glm(formula = vs ~ hp + mpg + gear, family = binomial, data =
mtcars)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.68166 -0.23743 -0.00945 0.30884 1.55688
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 11.95183 8.00322 1.493 0.1353
hp -0.07322 0.03440 -2.129 0.0333 *
mpg 0.16051 0.27538 0.583 0.5600
gear -1.66526 1.76407 -0.944 0.3452
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 43.860 on 31 degrees of freedom
Residual deviance: 15.651 on 28 degrees of freedom
AIC: 23.651
Number of Fisher Scoring iterations: 7