Multiple Logistic Regression using R

 

Also using the modified mpg data file with new variable cyl_two, which is defined as = 1 if cyl >= 6 or = 0 if cyl < 6.Cyl_two will be used as outcome variable and use highway mpg (hwy) as predictor variable.

> mpg$cyl_two <- NA
> mpg[which(mpg$cyl >= 6), ]$cyl_two <- 1
> mpg[which(mpg$cyl < 6), ]$cyl_two <- 0
> attach(mpg)
> summary(glm(cyl_two ~ hwy + factor(drv), family = binomial))

Call:
glm(formula = cyl_two ~ hwy + factor(drv), family = binomial)

Deviance Residuals: 
     Min       1Q  Median      3Q     Max 
-2.22888 -0.29840 0.04063 0.28538 1.90777

Coefficients:
             Estimate Std. Error z value Pr(>|z|) 
(Intercept)   18.0720     2.5603   7.059 1.68e-12 ***
hwy           -0.7838     0.1105  -7.091 1.33e-12 ***
factor(drv)f   3.0140     0.7017   4.295 1.74e-05 ***
factor(drv)r  19.8819  1670.7779   0.012 0.991 
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)
    Null deviance: 306.66 on 233 degrees of freedom
Residual deviance: 120.34 on 230 degrees of freedom
AIC: 128.34

Number of Fisher Scoring iterations: 18

 

 

See Also:

Do the same test in SAS

Leave a Reply

Your email address will not be published. Required fields are marked *