MSE 598-DM Spring 2021

Generalized Linear Model Exercise

psych.txt contains six columns. The column “ill” is the binary Y variable with 0 representing healthy and 1 representing mentally ill. The five x columns, x1, x2, x3, x4, x5, represent scores (1 to 4) on five questions, where higher values are expected to be healthier. We will fit a glm for Y using the x variables.

Code in R:

psych <- read.table("psych.txt", header=TRUE)
psychfit1 <- glm(ill ~ x1 + x2 + x3 + x4 + x5, family=binomial, data=psych)

Questions for part 1

Try using the total score only:

xsum <- apply(psych[,2:6], 1, sum)
psychfit2 <- glm(ill ~ xsum, family=binomial, data=psych)
summary(psychfit2)

Plot fitted probabilities of illness versus the total score: plot(xsum, fitted(psychfit2), xlab=“Total Score”, ylab=“Fitted Probability of Illness”)

Question for part 2