Sameer Mathur
\( Default = \beta_0 + \beta_1*CreditLimit + \beta_2*Education + \beta_3*Education*CreditLimit \)
\[ log\frac{p}{1-p} = \beta_0 + \beta_1*CreditLimit + \beta_2*Education2 + \beta_3*Education3 + \beta_4*Education4 \]
\[ + \beta_5*Education2*CreditLimit + \beta_6*Education3*CreditLimit \]
\[ + \beta_7*Education4*CreditLimit \]
….(2)
# fitting logistic regression model with interaction
Model2 <- glm(Default ~ CreditLimit
+ Education
+ Education*CreditLimit,
data = CCdefault.dt,
family = binomial())
# summary of the model
summary(Model2)
Call:
glm(formula = Default ~ CreditLimit + Education + Education *
CreditLimit, family = binomial(), data = CCdefault.dt)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.8191 0.4536 0.6529 0.7733 0.8940
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 9.262e-01 4.470e-02 20.719 < 2e-16 ***
CreditLimit 2.555e-06 2.005e-07 12.747 < 2e-16 ***
Education2 -2.493e-01 5.453e-02 -4.572 4.83e-06 ***
Education3 -2.507e-01 6.689e-02 -3.748 0.000178 ***
Education4 -1.318e-01 9.503e-01 -0.139 0.889700
CreditLimit:Education2 1.125e-06 2.824e-07 3.983 6.80e-05 ***
CreditLimit:Education3 9.762e-07 4.067e-07 2.400 0.016390 *
CreditLimit:Education4 8.732e-06 5.802e-06 1.505 0.132360
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 31427 on 29600 degrees of freedom
Residual deviance: 30610 on 29593 degrees of freedom
AIC: 30626
Number of Fisher Scoring iterations: 6
AIC of Model1 = 30639
AIC of Model2 = 30626
AIC of Model2 < AIC of Model1
newdata <- data.frame(CreditLimit = 100000, Education = "2")
probability <- predict(Model2, newdata, type= "response")
probability
1
0.7397817
\[ log\frac{p}{1-p} = \beta_0 + \beta_1*CreditLimit + \beta_2*Education2 + \beta_3*Education3 \] \[ + \beta_4*Education4 + \beta_5*Education2*CreditLimit + \beta_6*Education3*CreditLimit \] \[ + \beta_7*Education4*CreditLimit \]
\[ log\frac{p}{1-p} = \beta_0 + \beta_1*CreditLimit \]
\[ \frac{\partial}{\partial (CreditLimit)}log\frac{p}{1-p} = \beta_1 \]
\[ \frac{\partial}{\partial (CreditLimit)}log\frac{p}{1-p} = 0.000002555 \]
\[ \partial log\frac{p}{1-p} = 0.000002555* \partial (CreditLimit) \]
\[ \partial log\frac{p}{1-p} = 0.000002555* \partial (CreditLimit) \]
\[ \partial log\frac{p}{1-p} = 0.000002555*10000 \]
\[ \partial log\frac{p}{1-p} = 0.02555 \]
\[ \partial (p) = \frac{exp(0.02555)}{1 + exp(0.02555)} \]
\[ \partial (p) = 0.5063872 \]
\[ log\frac{p}{1-p} = \beta_0 + \beta_1*CreditLimit + \beta_2*Education2 + \beta_3*Education3 \] \[ + \beta_4*Education4 + \beta_5*Education2*CreditLimit + \beta_6*Education3*CreditLimit \] \[ + \beta_7*Education4*CreditLimit \]
\[ log\frac{p}{1-p} = (\beta_0 + \beta_2) + (\beta_1+\beta_5)*CreditLimit \]
\[ \frac{\partial}{\partial (CreditLimit)}log\frac{p}{1-p} = \beta_1 + \beta_5*Education2 \]
\[ \frac{\partial}{\partial (CreditLimit)}log\frac{p}{1-p} = 0.000002555 + 0.000001125*1 \]
\[ \frac{\partial}{\partial (CreditLimit)}log\frac{p}{1-p} = 0.00000368 \]
\[ \partial log\frac{p}{1-p} = 0.00000368* \partial (CreditLimit) \]
\[ \partial log\frac{p}{1-p} = 0.00000368* \partial (CreditLimit) \]
\[ \partial log\frac{p}{1-p} = 0.00000368*10000 \]
\[ \partial log\frac{p}{1-p} = 0.0368 \]
\[ \partial (p) = \frac{exp(0.0368)}{1 + exp(0.0368)} \]
\[ \partial (p) = 0.509199 \]