Data
1. Pearson correlation coefficient.
2. Logistic regression model
3. Effectiveness of the forecasting equation
4. Pseudo square index Nagelkerke R2
5. Exponential coefficients and 95% confidence intervals
The above example is contained in the paragraph 4.4 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
# data records for 20 customers: Family income (income), dept as percent of family income (deptinc) and failure to pay (default).
income = c(31, 55, 120, 25, 38, 16, 23, 64, 29, 100, 72, 61, 26, 176, 49, 25, 67, 28, 19, 41)
debtinc = c(17, 6, 3, 10, 4, 2, 5, 10, 16, 9, 8, 6, 2, 9, 9, 20, 31, 17, 24, 16)
default = c(1, 0,0,0,1,1,0,0,1,0,0,0,0,0,0,1,1,1,1,1)
default = factor(default, levels = c(0, 1), labels = c("Normal repayment", "Failure to pay"))
lr.data.frame = data.frame(income, debtinc, default)
1. Pearson correlation coefficient.
cor.test(income, debtinc)
2. Logistic regression model
fit = glm(default ~ income + debtinc,data=lr.data.frame,family=binomial())
summary(fit)
3. Effectiveness of the forecasting equation
theProbs = fitted(fit)
table(theProbs>0.5, lr.data.frame$default)
4. Pseudo square index Nagelkerke R2
library(rms)
model1 = lrm(default ~ income + debtinc, data = lr.data.frame)
print(model1)
5. Exponential coefficients and 95% confidence intervals
exp(coef(fit))
exp(confint(fit))
The above example is contained in the paragraph 4.4 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
Comments
Post a Comment