STA 542 HW5 (Ch5&6) Question: 1 2 Total Points: XXXXXXXXXX Score: 1. Data file “data/drinking.txt" has the result of cross classifying a sample of people from the MBTI Step II National Sample...

1 answer below »

View more »
Answered 8 days AfterMar 20, 2021

Answer To: STA 542 HW5 (Ch5&6) Question: 1 2 Total Points: XXXXXXXXXX Score: 1. Data file “data/drinking.txt"...

Abr Writing answered on Mar 28 2021
168 Votes
sta542.docx
STA 542
HW5
28/03/2021
Question 1
Loading the data into R Workspace
data <- read.table("drinking.txt")
Correcting the data types for four binary scales of the Myers–Briggs personality test
data$F1 <- as.factor(
data$F1)
data$F2 <- as.factor(revalue(as.character(data$F2),
c("TRUE" = "T",
"FALSE" = "F")))
data$F3 <- as.factor(data$F3)
data$F4 <- as.factor(data$F4)
Part (a)
summary(
model <- glm(Yes/(Yes+No) ~ F1 + F2 + F3 + F4,
weights = Yes + No,
family = binomial(link = "logit"),
data = data)
)
Call:
glm(formula = Yes/(Yes + No) ~ F1 + F2 + F3 + F4, family = binomial(link = "logit"),
data = data, weights = Yes + No)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.2712 -0.8062 -0.1063 0.1124 1.5807
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.1140 0.2715 -7.788 6.82e-15 ***
F1P 0.2022 0.2266 0.893 0.37209
F2T 0.6873 0.2206 3.116 0.00184 **
F3S -0.4292 0.2340 -1.834 0.06664 .
F4I -0.5550 0.2170 -2.558 0.01053 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 30.488 on 15 degrees of freedom
Residual deviance: 11.149 on 11 degrees of freedom
AIC: 73.99
Number of Fisher Scoring iterations: 4
The above equation can also be written as:
Part (b)
pred.prob <- fitted(model)
lp <- predict(model, se.fit = TRUE)
LB <- lp$fit - 1.96*lp$se.fit
UB <- lp$fit + 1.96*lp$se.fit
LB.p <- exp(LB)/(1+exp(LB))
UB.p <- exp(UB)/(1+exp(UB))
out <- data.frame(data$F1, data$F2, data$F3, data$F4,
pred.prob,
LB.p,
UB.p)
out
data.F1 data.F2 data.F3 data.F4 pred.prob LB.p UB.p
1 J T S E 0.13518600 0.09311660 0.19223318
2 P T S E 0.16061850 0.10468282 0.23848133
3 J F S E 0.07288479 0.04757773 0.11009687
4 P F S E 0.08778634 0.05694528 0.13297541
5 J T N E 0.19361150 0.12222927...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30