ISLR Home

# Question

p170

Suppose we collect data for a group of students in a statistics class with variables X1 = hours studied, X2 = undergrad GPA, and Y = receive an A. We fit a logistic regression and produce estimated coefficient, $$\hat{\beta_0} = −6, \hat{\beta_1} = 0.05, \hat{\beta_2} = 1$$.

1. Estimate the probability that a student who studies for 40h and has an undergrad GPA of 3.5 gets an A in the class.

2. How many hours would the student in part (a) need to study to have a 50% chance of getting an A in the class?

See page 134-135

Use the Logistic Regression Formula Y=ex/(1+ex) x = b0 + b1x1 + b2x2

Y = e^ b0 + b1 * x1
----------------
1 + e^ b0 + b1 * x1

# 6a

b0 = -6 b1 = .05 b2 = 1

x1 = 40 x2 = 3.5

y0 = b0 + b1 * x1 + b2 * x2
y0
y = exp(y0)/(1 + exp(y0))

y # 0.3775407 = 37.7%

# 6b

Use the Logistic Regression Formula

$Y=e^x/(1+e^x) \\ x = b0 + b1*x1 + b2*x2$

• Y = 0.5
• x2 = 3.5 (from a)
0.5 = e^-6 + 0.05X + 1*3.5
------------------------
1 + e^-6 + 0.05X + 1*3.5
(1 + e^-6 + 0.05X + 1*3.5) * 0.5 = e^-6 + 0.05X + 1*3.5
(0.5 + 0.5 * (e^-6 + 0.05X + 1*3.5)   = e^-6 + 0.05X + 3.5
0.5 = 0.5 * e^-6 + 0.05X + 3.5
1 = e^-6 + 0.05X + 3.5
log(1) = log(e^-6 + 0.05X + 3.5)
0 = -6 + 0.05X + 3.5
0 = -2.5 + 0.05X
2.5 = 0.05X
50 = X

Solve for x1 Will be taking the log of both sides

log(1) # 0 x1 = 50