Wednesday, July 5, 2017

Notes for Logistic regression in R on July 5th

Steps to take for Logistic Regression in R:

(1) Load data
(2) attach(data-sample)
(3) summary(data-sample)
(4) ced.del <- cbind(sDel, sNoDel)
(5) summary(ced.del)
(6) duckie <- glm(ced.del ~ cat + follows + factor(class), family=binomial)
(7) duckie
(8) summary(duckie)
(9) anova(duckie, test="Chisq")
(10) plot(duckie)

Revised:

fico <- read.table("/home/brent/Documents/fico.csv", header=TRUE, sep=",",
  na.strings="NA", dec=".", strip.white=TRUE)

attach(fico)

duckie <- glm(approved ~ creditScore, family=binomial)

summary(duckie)

------

> summary(duckie)

Call:
glm(formula = approved ~ creditScore, family = binomial)

Deviance Residuals:
   Min      1Q  Median      3Q     Max 
-1.408  -1.338   0.959   1.010   1.149 

Coefficients:
             Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.223592  17.177351  -0.362    0.717
creditScore  0.009605   0.024893   0.386    0.700

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 20.190  on 14  degrees of freedom
Residual deviance: 20.038  on 13  degrees of freedom
AIC: 24.038

Number of Fisher Scoring iterations: 4

Use the intercept and the credit score to solve for the predicted probability:
p ^ = βo + x1β1 1 + βo + x1β1

With the coefficient estimates we have:
p ^ = -6.223592 + 0.009605x1 1 + -6.223592 + 0.009605x1

No comments:

Post a Comment