Study time Pass Study time Pass 2 0 15 1 4 0 16 1 5 0 17 0 6 0 19 1 7 0 20 1 8 1
ID: 3362582 • Letter: S
Question
Study time Pass Study time Pass 2 0 15 1 4 0 16 1 5 0 17 0 6 0 19 1 7 0 20 1 8 1 22 0 8 1 23 1 9 0 24 1 10 0 27 1 10 0 30 0 11 1 31 1 12 1 32 1 13 0 Consider the data set above about the relationship between weeks of study and passing a certification exam. Pass = 1 if passed the exam, and Pass = 0 if not passed. Compute the logistic regression model using the data above. What is the predicted probability that a person studying for 18 weeks will pass the certification exam? (Round your answer to 3 decimal places.)
Explanation / Answer
We shall analyse this in the open source statistical package, R . The complete R snippet is as follows
Time <-c(2,15,4,16,5,17,6,19,7,20,8,22,8,23,9,24,10,27,10,30,11,31,12,32,13)
Pass <- c(0,1,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,1,0,0,1,1,1,1,0)
data.df <- cbind.data.frame(Time,Pass=as.factor(Pass))
model <- glm(Pass ~.,family=binomial(link='logit'),data=data.df)
summary(model)
##
newdata <- data.frame(Time=18)
##
predict(model,newdata,type = "link")
The results are
> predict(model,newdata,type = "link") ## the probability is
1
0.4646496
The model is
> summary(model)
Call:
glm(formula = Pass ~ ., family = binomial(link = "logit"), data = data.df)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.0184 -0.9317 0.4726 0.9415 1.4985
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.68420 0.94508 -1.782 0.0747 .
Time 0.11938 0.05889 2.027 0.0427 *
---
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: 29.374 on 23 degrees of freedom
AIC: 33.374
Number of Fisher Scoring iterations: 4