library(readr)
missile <- read.table("C:/Users/Desktop/Downloads/missile.txt",header = TRUE)
missile
##     x1      x2 y
## 1  400 2.58712 0
## 2  220 2.83445 1
## 3  490 2.95819 0
## 4  210 3.03145 1
## 5  500 3.12618 0
## 6  270 2.27379 0
## 7  200 1.75191 1
## 8  470 3.79009 0
## 9  480 4.72141 0
## 10 310 4.40155 1
## 11 240 3.85747 1
## 12 490 3.63706 0
## 13 420 3.22118 0
## 14 330 2.75392 1
## 15 280 3.31236 1
## 16 210 5.09166 1
## 17 300 6.21180 1
## 18 470 5.21862 1
## 19 230 2.58414 0
## 20 430 2.05767 0
## 21 460 1.66235 0
## 22 220 0.77621 1
## 23 250 0.89889 1
## 24 200 1.73104 1
## 25 390 1.92354 0
missile$y <- factor(missile$y)

logitmod = glm(y ~ x1, data = missile, family = "binomial")
summary(logitmod)
## 
## Call:
## glm(formula = y ~ x1, family = "binomial", data = missile)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0620  -0.4868   0.3915   0.5476   2.1682  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept)  6.070884   2.108996   2.879  0.00399 **
## x1          -0.017705   0.006076  -2.914  0.00357 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 34.617  on 24  degrees of freedom
## Residual deviance: 20.364  on 23  degrees of freedom
## AIC: 24.364
## 
## Number of Fisher Scoring iterations: 4

(i) Based on the output, write the equation of the logistic regression model.

(ii) Does the model deviance indicate that the logistic regression model from part (i) is adequate?.

(iii) Provide an interpretation of the parameter β1 of the model.

logitmod = glm(y ~x1+x2, data = missile, family = "binomial")
summary(logitmod)
## 
## Call:
## glm(formula = y ~ x1 + x2, family = "binomial", data = missile)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.21945  -0.43285   0.08161   0.46436   1.42620  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept)  5.126227   2.199315   2.331  0.01976 * 
## x1          -0.024672   0.009079  -2.717  0.00658 **
## x2           1.130875   0.674592   1.676  0.09366 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 34.617  on 24  degrees of freedom
## Residual deviance: 16.197  on 22  degrees of freedom
## AIC: 22.197
## 
## Number of Fisher Scoring iterations: 6

(iv) Considering the predictor wind speed in the model, refit the model and write the updated logistic regression model.

(v) Based on the updated logistic model, does the model deviance indicate that the model is adequate. Explain briefly.