Sei sulla pagina 1di 3

> rm(list=ls()) # clear all lists

>
> ss <- read.csv("C:/Users/sankalpn/Desktop/DATA/ss.csv") # read modelling data to ss
> View(ss) # View Data Set
> ss$country_reg_r=factor(ss$country_reg_r) # converting conuntry_reg to factor
> ss$ad_exp_r=factor(ss$ad_exp_r) # converting ad_exp to factor
>
> ds4 <- read.csv("C:/Users/sankalpn/Desktop/DATA/ds4.csv") # read prediction data to
ds4
> View(ds4) # View Data Set
> ds4$country_reg_r=factor(ds4$country_reg_r) # converting conuntry_reg to factor
> ds4$ad_exp_r=factor(ds4$ad_exp_r) # converting ad_exp this to factor
>
>
> # Logistic Regression
> logr <- glm(card_offer_r ~ country_reg_r + ad_exp_r + est_income + hold_bal +
pref_cust_prob + imp_cscore + RiskScore + imp_crediteval + axio_score, data = ss,
family = binomial())
> summary (logr)
Call:
glm(formula = card_offer_r ~ country_reg_r + ad_exp_r + est_income +
hold_bal + pref_cust_prob + imp_cscore + RiskScore + imp_crediteval +
axio_score, family = binomial(), data = ss)
Deviance Residuals:
Min
1Q Median
3Q
Max
-4.6861 -0.0542 -0.0058 -0.0002 3.2586
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.017e+01 9.646e-01 -31.275 <2e-16 ***
country_reg_r1 -6.061e+00 1.632e-01 -37.127 <2e-16 ***
ad_exp_r1
-6.209e-02 7.146e-02 -0.869 0.385
est_income
1.469e-04 3.212e-06 45.716 <2e-16 ***
hold_bal
-1.088e-01 3.892e-03 -27.969 <2e-16 ***
pref_cust_prob 2.475e+01 4.897e-01 50.540 <2e-16 ***
imp_cscore
1.192e-02 1.093e-03 10.908 <2e-16 ***
RiskScore
6.440e-04 3.984e-04 1.616 0.106
imp_crediteval 4.679e-02 5.044e-02 0.928 0.354
axio_score
9.278e-02 1.253e-01 0.741 0.459
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 25296.5 on 29999 degrees of freedom
Residual deviance: 5194.9 on 29990 degrees of freedom
AIC: 5214.9
Number of Fisher Scoring iterations: 9
>
> # Step wise Regression to remove unimportant factors (typically with p value > 0.05)
> logr.step <- stepAIC(logr)
Start: AIC=5214.89
card_offer_r ~ country_reg_r + ad_exp_r + est_income + hold_bal +
pref_cust_prob + imp_cscore + RiskScore + imp_crediteval +
axio_score

Df Deviance
AIC
- axio_score
1 5195.4 5213.4
- ad_exp_r
1 5195.6 5213.6
- imp_crediteval 1 5195.8 5213.8
<none>
5194.9 5214.9
- RiskScore
1 5197.5 5215.5
- imp_cscore
1 5317.9 5335.9
- hold_bal
1 6250.0 6268.0
- country_reg_r 1 7504.1 7522.1
- est_income
1 12472.8 12490.8
- pref_cust_prob 1 21879.3 21897.3
Step: AIC=5213.44
card_offer_r ~ country_reg_r + ad_exp_r + est_income + hold_bal +
pref_cust_prob + imp_cscore + RiskScore + imp_crediteval
Df Deviance
AIC
- ad_exp_r
1 5196.2 5212.2
- imp_crediteval 1 5196.3 5212.3
<none>
5195.4 5213.4
- RiskScore
1 5198.1 5214.1
- imp_cscore
1 5318.6 5334.6
- hold_bal
1 6251.0 6267.0
- country_reg_r 1 7504.9 7520.9
- est_income
1 12472.8 12488.8
- pref_cust_prob 1 21879.3 21895.3
Step: AIC=5212.2
card_offer_r ~ country_reg_r + est_income + hold_bal + pref_cust_prob +
imp_cscore + RiskScore + imp_crediteval
Df Deviance
AIC
- imp_crediteval 1 5197.1 5211.1
<none>
5196.2 5212.2
- RiskScore
1 5198.8 5212.8
- imp_cscore
1 5319.3 5333.3
- hold_bal
1 6252.7 6266.7
- country_reg_r 1 7505.4 7519.4
- est_income
1 12473.3 12487.3
- pref_cust_prob 1 21879.5 21893.5
Step: AIC=5211.07
card_offer_r ~ country_reg_r + est_income + hold_bal + pref_cust_prob +
imp_cscore + RiskScore
Df Deviance
AIC
<none>
5197.1 5211.1
- RiskScore
1 5199.7 5211.7
- imp_cscore
1 5951.6 5963.6
- hold_bal
1 6253.3 6265.3
- country_reg_r 1 7505.4 7517.4
- est_income
1 12473.4 12485.4
- pref_cust_prob 1 21879.5 21891.5
> summary (logr.step)
Call:
glm(formula = card_offer_r ~ country_reg_r + est_income + hold_bal +
pref_cust_prob + imp_cscore + RiskScore, family = binomial(),

data = ss)
Deviance Residuals:
Min
1Q Median
3Q
Max
-4.6756 -0.0545 -0.0058 -0.0002 3.2700
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.955e+01 6.927e-01 -42.652 <2e-16 ***
country_reg_r1 -6.059e+00 1.632e-01 -37.124 <2e-16 ***
est_income
1.468e-04 3.211e-06 45.718 <2e-16 ***
hold_bal
-1.089e-01 3.893e-03 -27.984 <2e-16 ***
pref_cust_prob 2.474e+01 4.893e-01 50.551 <2e-16 ***
imp_cscore
1.282e-02 5.140e-04 24.944 <2e-16 ***
RiskScore
6.431e-04 3.983e-04 1.614 0.106
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 25296.5 on 29999 degrees of freedom
Residual deviance: 5197.1 on 29993 degrees of freedom
AIC: 5211.1
Number of Fisher Scoring iterations: 9
>
>
>
>
>
>
>

# Predicting Values
ds4$card_offer <- predict(logr.step,type="response",newdata = ds4)
View(ds4)
# Exporting CSV
write.csv(ds4,file='dsout1.csv')

Potrebbero piacerti anche