library(blorr)
library(magrittr)
model <- glm(y ~ job + housing + contact + poutcome + duration + month +
campaign + loan + marital + education + day + balance + previous,
data = bank_marketing, family = binomial(link = 'logit'))
blr_regress(model)
#> - Creating model overview.
#> - Creating response profile.
#> - Extracting maximum likelihood estimates.
#> - Estimating concordant and discordant pairs.
#> Model Overview
#> ------------------------------------------------------------------------
#> Data Set Resp Var Obs. Df. Model Df. Residual Convergence
#> ------------------------------------------------------------------------
#> data y 4521 4520 4481 TRUE
#> ------------------------------------------------------------------------
#>
#> Response Summary
#> --------------------------------------------------------
#> Outcome Frequency Outcome Frequency
#> --------------------------------------------------------
#> 0 4004 1 517
#> --------------------------------------------------------
#>
#> Maximum Likelihood Estimates
#> -------------------------------------------------------------------------
#> Parameter DF Estimate Std. Error z value Pr(>|z|)
#> -------------------------------------------------------------------------
#> (Intercept) 1 -6.0954 0.3773 -16.1557 0.0000
#> jobtechnician 1 -0.0068 0.2080 -0.0325 0.9741
#> jobentrepreneur 1 -0.3684 0.3804 -0.9686 0.3328
#> jobblue-collar 1 -0.1024 0.2411 -0.4246 0.6711
#> jobunknown 1 -0.9139 0.9521 -0.9599 0.3371
#> jobretired 1 0.5864 0.2862 2.0488 0.0405
#> jobadmin. 1 0.3936 0.2407 1.6350 0.1020
#> jobservices 1 0.2296 0.2680 0.8568 0.3916
#> jobself-employed 1 -0.0333 0.3138 -0.1061 0.9155
#> jobunemployed 1 -0.3802 0.3786 -1.0040 0.3154
#> jobhousemaid 1 -0.4823 0.4276 -1.1280 0.2593
#> jobstudent 1 -0.0691 0.3682 -0.1877 0.8511
#> housingno 1 0.5906 0.1390 4.2494 0.0000
#> contactcellular 1 1.7275 0.2391 7.2249 0.0000
#> contacttelephone 1 1.3937 0.3253 4.2844 0.0000
#> poutcomefailure 1 0.0185 0.2139 0.0865 0.9311
#> poutcomeother 1 0.6038 0.2833 2.1309 0.0331
#> poutcomesuccess 1 2.8899 0.2575 11.2208 0.0000
#> duration 1 0.0044 2e-04 20.6753 0.0000
#> monthjun 1 1.0020 0.2522 3.9728 1e-04
#> monthjul 1 -0.1291 0.2303 -0.5605 0.5752
#> monthaug 1 -0.2074 0.2384 -0.8697 0.3844
#> monthoct 1 1.5325 0.3355 4.5680 0.0000
#> monthnov 1 -0.1869 0.2481 -0.7531 0.4514
#> monthdec 1 0.9879 0.7732 1.2777 0.2014
#> monthjan 1 -0.7318 0.3783 -1.9344 0.0531
#> monthfeb 1 0.4410 0.2564 1.7199 0.0855
#> monthmar 1 1.5231 0.3952 3.8537 1e-04
#> monthapr 1 0.1970 0.2412 0.8166 0.4141
#> monthsep 1 1.6979 0.3908 4.3449 0.0000
#> campaign 1 -0.0844 0.0307 -2.7462 0.0060
#> loanno 1 0.7052 0.2062 3.4195 6e-04
#> maritalsingle 1 0.3590 0.1328 2.7033 0.0069
#> maritaldivorced 1 -0.1420 0.2062 -0.6887 0.4910
#> educationsecondary 1 -0.3312 0.1711 -1.9361 0.0529
#> educationunknown 1 0.3370 0.3026 1.1136 0.2655
#> educationprimary 1 -0.3731 0.2408 -1.5490 0.1214
#> day 1 0.0045 0.0084 0.5364 0.5917
#> balance 1 0.0000 0.0000 0.4029 0.6870
#> previous 1 -0.0310 0.0398 -0.7783 0.4364
#> -------------------------------------------------------------------------
#>
#> Association of Predicted Probabilities and Observed Responses
#> ---------------------------------------------------------------
#> % Concordant 0.9099 Somers' D 0.8197
#> % Discordant 0.0901 Gamma 0.8197
#> % Tied 0.0000 Tau-a 0.1661
#> Pairs 2070068 c 0.9099
#> ---------------------------------------------------------------
blr_regress(y ~ marital + education + contact, data = bank_marketing)
#> - Creating model overview.
#> - Creating response profile.
#> - Extracting maximum likelihood estimates.
#> - Estimating concordant and discordant pairs.
#> Model Overview
#> ------------------------------------------------------------------------
#> Data Set Resp Var Obs. Df. Model Df. Residual Convergence
#> ------------------------------------------------------------------------
#> data y 4521 4520 4513 TRUE
#> ------------------------------------------------------------------------
#>
#> Response Summary
#> --------------------------------------------------------
#> Outcome Frequency Outcome Frequency
#> --------------------------------------------------------
#> 0 4004 1 517
#> --------------------------------------------------------
#>
#> Maximum Likelihood Estimates
#> -------------------------------------------------------------------------
#> Parameter DF Estimate Std. Error z value Pr(>|z|)
#> -------------------------------------------------------------------------
#> (Intercept) 1 -3.0830 0.1658 -18.5890 0.0000
#> maritalsingle 1 0.4167 0.1039 4.0097 1e-04
#> maritaldivorced 1 0.0539 0.1606 0.3353 0.7374
#> educationsecondary 1 -0.3436 0.1060 -3.2425 0.0012
#> educationunknown 1 0.1344 0.2348 0.5724 0.5671
#> educationprimary 1 -0.2468 0.1559 -1.5831 0.1134
#> contactcellular 1 1.3754 0.1496 9.1950 0.0000
#> contacttelephone 1 1.2645 0.2217 5.7031 0.0000
#> -------------------------------------------------------------------------
#>
#> Association of Predicted Probabilities and Observed Responses
#> ----------------------------------------------------------------
#> % Concordant 0.6092 Somers' D 0.3369
#> % Discordant 0.3022 Gamma 0.3070
#> % Tied 0.0886 Tau-a 0.0622
#> Pairs 2070068 c 0.6535
#> ----------------------------------------------------------------
blr_regress(model, odd_conf_limit = TRUE)
#> - Creating model overview.
#> - Creating response profile.
#> - Extracting maximum likelihood estimates.
#> - Computing odds ratio estimates.
#> - Estimating concordant and discordant pairs.
#> Model Overview
#> ------------------------------------------------------------------------
#> Data Set Resp Var Obs. Df. Model Df. Residual Convergence
#> ------------------------------------------------------------------------
#> data y 4521 4520 4481 TRUE
#> ------------------------------------------------------------------------
#>
#> Response Summary
#> --------------------------------------------------------
#> Outcome Frequency Outcome Frequency
#> --------------------------------------------------------
#> 0 4004 1 517
#> --------------------------------------------------------
#>
#> Maximum Likelihood Estimates
#> -------------------------------------------------------------------------
#> Parameter DF Estimate Std. Error z value Pr(>|z|)
#> -------------------------------------------------------------------------
#> (Intercept) 1 -6.0954 0.3773 -16.1557 0.0000
#> jobtechnician 1 -0.0068 0.2080 -0.0325 0.9741
#> jobentrepreneur 1 -0.3684 0.3804 -0.9686 0.3328
#> jobblue-collar 1 -0.1024 0.2411 -0.4246 0.6711
#> jobunknown 1 -0.9139 0.9521 -0.9599 0.3371
#> jobretired 1 0.5864 0.2862 2.0488 0.0405
#> jobadmin. 1 0.3936 0.2407 1.6350 0.1020
#> jobservices 1 0.2296 0.2680 0.8568 0.3916
#> jobself-employed 1 -0.0333 0.3138 -0.1061 0.9155
#> jobunemployed 1 -0.3802 0.3786 -1.0040 0.3154
#> jobhousemaid 1 -0.4823 0.4276 -1.1280 0.2593
#> jobstudent 1 -0.0691 0.3682 -0.1877 0.8511
#> housingno 1 0.5906 0.1390 4.2494 0.0000
#> contactcellular 1 1.7275 0.2391 7.2249 0.0000
#> contacttelephone 1 1.3937 0.3253 4.2844 0.0000
#> poutcomefailure 1 0.0185 0.2139 0.0865 0.9311
#> poutcomeother 1 0.6038 0.2833 2.1309 0.0331
#> poutcomesuccess 1 2.8899 0.2575 11.2208 0.0000
#> duration 1 0.0044 2e-04 20.6753 0.0000
#> monthjun 1 1.0020 0.2522 3.9728 1e-04
#> monthjul 1 -0.1291 0.2303 -0.5605 0.5752
#> monthaug 1 -0.2074 0.2384 -0.8697 0.3844
#> monthoct 1 1.5325 0.3355 4.5680 0.0000
#> monthnov 1 -0.1869 0.2481 -0.7531 0.4514
#> monthdec 1 0.9879 0.7732 1.2777 0.2014
#> monthjan 1 -0.7318 0.3783 -1.9344 0.0531
#> monthfeb 1 0.4410 0.2564 1.7199 0.0855
#> monthmar 1 1.5231 0.3952 3.8537 1e-04
#> monthapr 1 0.1970 0.2412 0.8166 0.4141
#> monthsep 1 1.6979 0.3908 4.3449 0.0000
#> campaign 1 -0.0844 0.0307 -2.7462 0.0060
#> loanno 1 0.7052 0.2062 3.4195 6e-04
#> maritalsingle 1 0.3590 0.1328 2.7033 0.0069
#> maritaldivorced 1 -0.1420 0.2062 -0.6887 0.4910
#> educationsecondary 1 -0.3312 0.1711 -1.9361 0.0529
#> educationunknown 1 0.3370 0.3026 1.1136 0.2655
#> educationprimary 1 -0.3731 0.2408 -1.5490 0.1214
#> day 1 0.0045 0.0084 0.5364 0.5917
#> balance 1 0.0000 0.0000 0.4029 0.6870
#> previous 1 -0.0310 0.0398 -0.7783 0.4364
#> -------------------------------------------------------------------------
#>
#> Odds Ratio Estimates
#> ---------------------------------------------------------------------
#> Effects Estimate 95% Wald Conf. Limit
#> ---------------------------------------------------------------------
#> jobtechnician 0.9933 0.6591 1.4907
#> jobentrepreneur 0.6918 0.3143 1.4082
#> jobblue-collar 0.9027 0.5617 1.4464
#> jobunknown 0.4010 0.0423 1.9591
#> jobretired 1.7976 1.0191 3.1339
#> jobadmin. 1.4822 0.9215 2.3696
#> jobservices 1.2582 0.7387 2.1157
#> jobself-employed 0.9673 0.5116 1.7564
#> jobunemployed 0.6838 0.3150 1.3983
#> jobhousemaid 0.6173 0.2558 1.3774
#> jobstudent 0.9332 0.4462 1.8944
#> housingno 1.8050 1.3756 2.3726
#> contactcellular 5.6266 3.5476 9.0674
#> contacttelephone 4.0299 2.1202 7.6052
#> poutcomefailure 1.0187 0.6660 1.5419
#> poutcomeother 1.8290 1.0369 3.1550
#> poutcomesuccess 17.9917 10.9518 30.0908
#> duration 1.0044 1.0040 1.0048
#> monthjun 2.7238 1.6590 4.4655
#> monthjul 0.8789 0.5585 1.3787
#> monthaug 0.8127 0.5086 1.2962
#> monthoct 4.6295 2.3828 8.9031
#> monthnov 0.8296 0.5070 1.3430
#> monthdec 2.6855 0.5405 11.5587
#> monthjan 0.4810 0.2235 0.9888
#> monthfeb 1.5543 0.9363 2.5615
#> monthmar 4.5865 2.0753 9.8396
#> monthapr 1.2177 0.7550 1.9466
#> monthsep 5.4624 2.5190 11.6901
#> campaign 0.9190 0.8624 0.9730
#> loanno 2.0242 1.3675 3.0737
#> maritalsingle 1.4320 1.1026 1.8565
#> maritaldivorced 0.8676 0.5732 1.2877
#> educationsecondary 0.7181 0.5138 1.0049
#> educationunknown 1.4007 0.7602 2.4973
#> educationprimary 0.6886 0.4278 1.1004
#> day 1.0045 0.9882 1.0211
#> balance 1.0000 1.0000 1.0000
#> previous 0.9695 0.8936 1.0441
#> ---------------------------------------------------------------------
#>
#> Association of Predicted Probabilities and Observed Responses
#> ---------------------------------------------------------------
#> % Concordant 0.9099 Somers' D 0.8197
#> % Discordant 0.0901 Gamma 0.8197
#> % Tied 0.0000 Tau-a 0.1661
#> Pairs 2070068 c 0.9099
#> ---------------------------------------------------------------
blr_model_fit_stats(model)
#> Model Fit Statistics
#> ---------------------------------------------------------------------------------
#> Log-Lik Intercept Only: -1607.330 Log-Lik Full Model: -1042.323
#> Deviance(4481): 2084.646 LR(39): 1130.013
#> Prob > LR: 0.000
#> MCFadden's R2 0.352 McFadden's Adj R2: 0.327
#> ML (Cox-Snell) R2: NaN Cragg-Uhler(Nagelkerke) R2: NaN
#> McKelvey & Zavoina's R2: 0.476 Efron's R2: 0.321
#> Count R2: 0.904 Adj Count R2: 0.161
#> BIC: 2421.306 AIC: 2164.646
#> ---------------------------------------------------------------------------------
model <- glm(y ~ marital + education + contact, data = bank_marketing,
family = binomial(link = 'logit'))
model2 <- glm(y ~ marital + education, data = bank_marketing,
family = binomial(link = 'logit'))
blr_multi_model_fit_stats(model, model2)
#> Measures Model 1 Model 2
#> 1 Log-Lik Intercept Only -1607.330 -1607.330
#> 2 Log-Lik Full Model -1529.506 -1586.114
#> 3 Deviance 3059.013 3172.228
#> 4 LR 155.646 42.431
#> 5 Prob > LR 0.000 0.000
#> 6 MCFadden's R2 0.048 0.013
#> 7 McFadden's Adj R2 0.043 0.009
#> 8 ML (Cox-Snell) R2 3075.013 3184.228
#> 9 Cragg-Uhler(Nagelkerke) R2 NaN NaN
#> 10 McKelvey & Zavoina's R2 3126.344 3222.727
#> 11 Efron's R2 0.128 0.025
#> 12 Count R2 0.032 0.010
#> 13 Adj Count R2 NaN NaN
#> 14 AIC 0.886 0.886
#> 15 BIC 0.000 0.000