Skip to contents

Multinominal Logistic Model

Usage

MLM_Model(Data, xvar, yvar)

Arguments

Data

The name of the Dataset.

xvar

X variables.

yvar

Y variable.

Value

The output from MLM_Model.

Details

Multi-nominal model is the generalized form of generalized logistic model and can be define as $$\pi_{i}^{h} = P(y_{i}^{h} = 1 | \bold{x}_{\bold{i}}^{h})$$ where \(h\) presents the class labels ("1-of-h") on the basis of an input vector \(x_j\), in our case \(x_j\) is loan types ("Formal Loan", "Informal Loan", "Both Loan", and "No Loan"). Furthermore,

\(y_{i}^h = 1\)if the weight w of \(x_j\) corresponds to belong a class and \(y_{i}^h=0\) otherwise. For \(i\) \(\in\) \(1,\ldots,h\) and the weight vectors w^i corresponds to class \(i\).

We set \({\bold{{w}}^{h}} = 0\) and the parameters to be learned are the weight vectors w^i for \(i\) \(\in\) \(1,\ldots,h-1\) . And the class probabilities must satisfy $$\sum_{i=1}^{h} P(y_{i}^{h} = 1 | \bold{x}_{\bold{i}}^{h}, \bold{w}) = 1.$$

Examples

yvar <- c("Loan.Type")
sample_data <- sample_data[c(1:750),]
xvar <- c("sex", "married", "age", "havejob", "educ", "political.afl",
"rural", "region", "fin.intermdiaries", "fin.knowldge", "income")
BchMk.MLM <- MLM_Model(sample_data, c(xvar, "networth"), yvar )
#> + Fold01: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 364.275000
#> iter  20 value 349.993215
#> iter  30 value 348.132163
#> iter  40 value 348.054675
#> final  value 348.053959 
#> converged
#> - Fold01: decay=0e+00 
#> + Fold01: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 366.551383
#> iter  20 value 353.548709
#> iter  30 value 352.181839
#> iter  40 value 352.097005
#> final  value 352.095989 
#> converged
#> - Fold01: decay=1e-01 
#> + Fold01: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 364.277301
#> iter  20 value 349.996916
#> iter  30 value 348.136493
#> iter  40 value 348.059033
#> final  value 348.058318 
#> converged
#> - Fold01: decay=1e-04 
#> + Fold02: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 443.570754
#> iter  20 value 384.960856
#> iter  30 value 352.538320
#> iter  40 value 344.812048
#> iter  50 value 344.345576
#> final  value 344.345291 
#> converged
#> - Fold02: decay=0e+00 
#> + Fold02: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 455.605668
#> iter  20 value 382.613784
#> iter  30 value 353.653999
#> iter  40 value 348.673023
#> iter  50 value 348.509703
#> final  value 348.509569 
#> converged
#> - Fold02: decay=1e-01 
#> + Fold02: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 443.584015
#> iter  20 value 384.965254
#> iter  30 value 352.492968
#> iter  40 value 344.817045
#> iter  50 value 344.350014
#> final  value 344.349775 
#> converged
#> - Fold02: decay=1e-04 
#> + Fold03: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 489.828340
#> iter  20 value 384.206322
#> iter  30 value 362.592686
#> iter  40 value 354.641152
#> iter  50 value 354.526822
#> final  value 354.526765 
#> converged
#> - Fold03: decay=0e+00 
#> + Fold03: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 497.910157
#> iter  20 value 390.379744
#> iter  30 value 362.646251
#> iter  40 value 358.407098
#> iter  50 value 358.328134
#> final  value 358.327852 
#> converged
#> - Fold03: decay=1e-01 
#> + Fold03: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 489.837728
#> iter  20 value 384.204240
#> iter  30 value 362.537731
#> iter  40 value 354.645598
#> iter  50 value 354.530918
#> final  value 354.530860 
#> converged
#> - Fold03: decay=1e-04 
#> + Fold04: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 747.212661 
#> iter  10 value 456.813060
#> iter  20 value 369.345519
#> iter  30 value 350.474542
#> iter  40 value 344.054112
#> iter  50 value 343.965802
#> iter  50 value 343.965800
#> iter  50 value 343.965800
#> final  value 343.965800 
#> converged
#> - Fold04: decay=0e+00 
#> + Fold04: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 747.212661 
#> iter  10 value 467.483579
#> iter  20 value 375.442704
#> iter  30 value 349.810962
#> iter  40 value 348.093411
#> iter  50 value 348.075721
#> iter  50 value 348.075719
#> iter  50 value 348.075719
#> final  value 348.075719 
#> converged
#> - Fold04: decay=1e-01 
#> + Fold04: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 747.212661 
#> iter  10 value 456.824689
#> iter  20 value 369.353322
#> iter  30 value 350.476989
#> iter  40 value 344.059007
#> iter  50 value 343.970247
#> iter  50 value 343.970246
#> iter  50 value 343.970246
#> final  value 343.970246 
#> converged
#> - Fold04: decay=1e-04 
#> + Fold05: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 454.564198
#> iter  20 value 375.895647
#> iter  30 value 353.935369
#> iter  40 value 347.467043
#> iter  50 value 347.371319
#> final  value 347.371306 
#> converged
#> - Fold05: decay=0e+00 
#> + Fold05: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 464.973931
#> iter  20 value 379.876784
#> iter  30 value 353.915531
#> iter  40 value 351.219655
#> iter  50 value 351.150661
#> final  value 351.150645 
#> converged
#> - Fold05: decay=1e-01 
#> + Fold05: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 751.371544 
#> iter  10 value 454.575618
#> iter  20 value 375.901987
#> iter  30 value 353.949227
#> iter  40 value 347.472747
#> iter  50 value 347.375332
#> final  value 347.375319 
#> converged
#> - Fold05: decay=1e-04 
#> + Fold06: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 360.994011
#> iter  20 value 344.187916
#> iter  30 value 342.589368
#> iter  40 value 342.439367
#> final  value 342.437864 
#> converged
#> - Fold06: decay=0e+00 
#> + Fold06: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 363.028043
#> iter  20 value 347.408506
#> iter  30 value 346.104049
#> iter  40 value 345.996028
#> iter  50 value 345.994094
#> final  value 345.994085 
#> converged
#> - Fold06: decay=1e-01 
#> + Fold06: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 360.996062
#> iter  20 value 344.191219
#> iter  30 value 342.593015
#> iter  40 value 342.443065
#> final  value 342.441562 
#> converged
#> - Fold06: decay=1e-04 
#> + Fold07: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 472.261822
#> iter  20 value 374.628529
#> iter  30 value 351.933868
#> iter  40 value 347.542492
#> iter  50 value 347.500880
#> final  value 347.498560 
#> converged
#> - Fold07: decay=0e+00 
#> + Fold07: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 484.240787
#> iter  20 value 379.265281
#> iter  30 value 354.781592
#> iter  40 value 351.718334
#> iter  50 value 351.681314
#> iter  50 value 351.681314
#> iter  50 value 351.681314
#> final  value 351.681314 
#> converged
#> - Fold07: decay=1e-01 
#> + Fold07: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 472.274962
#> iter  20 value 374.635454
#> iter  30 value 351.932197
#> iter  40 value 347.548088
#> iter  50 value 347.505440
#> final  value 347.503130 
#> converged
#> - Fold07: decay=1e-04 
#> + Fold08: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 459.718079
#> iter  20 value 375.599428
#> iter  30 value 351.233951
#> iter  40 value 344.638897
#> iter  50 value 344.386044
#> final  value 344.386019 
#> converged
#> - Fold08: decay=0e+00 
#> + Fold08: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 483.638037
#> iter  20 value 381.962440
#> iter  30 value 353.692247
#> iter  40 value 348.328545
#> iter  50 value 348.175001
#> final  value 348.174740 
#> converged
#> - Fold08: decay=1e-01 
#> + Fold08: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 459.735477
#> iter  20 value 375.639248
#> iter  30 value 351.235940
#> iter  40 value 344.642717
#> iter  50 value 344.390057
#> final  value 344.390030 
#> converged
#> - Fold08: decay=1e-04 
#> + Fold09: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 443.942467
#> iter  20 value 369.112430
#> iter  30 value 346.459203
#> iter  40 value 340.534452
#> iter  50 value 340.442128
#> final  value 340.442110 
#> converged
#> - Fold09: decay=0e+00 
#> + Fold09: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 457.687356
#> iter  20 value 371.313341
#> iter  30 value 346.852253
#> iter  40 value 344.558356
#> iter  50 value 344.475684
#> iter  50 value 344.475682
#> iter  50 value 344.475682
#> final  value 344.475682 
#> converged
#> - Fold09: decay=1e-01 
#> + Fold09: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 748.598955 
#> iter  10 value 443.957360
#> iter  20 value 369.119376
#> iter  30 value 346.428259
#> iter  40 value 340.539974
#> iter  50 value 340.446429
#> final  value 340.446412 
#> converged
#> - Fold09: decay=1e-04 
#> + Fold10: decay=0e+00 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 466.524964
#> iter  20 value 365.821449
#> iter  30 value 350.687420
#> iter  40 value 347.070899
#> iter  50 value 346.977851
#> final  value 346.977842 
#> converged
#> - Fold10: decay=0e+00 
#> + Fold10: decay=1e-01 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 477.977482
#> iter  20 value 375.774098
#> iter  30 value 356.609507
#> iter  40 value 351.794751
#> iter  50 value 351.288776
#> final  value 351.288551 
#> converged
#> - Fold10: decay=1e-01 
#> + Fold10: decay=1e-04 
#> # weights:  56 (39 variable)
#> initial  value 749.985249 
#> iter  10 value 466.537478
#> iter  20 value 365.833152
#> iter  30 value 350.703925
#> iter  40 value 347.088672
#> iter  50 value 346.995548
#> iter  60 value 346.986247
#> final  value 346.983098 
#> converged
#> - Fold10: decay=1e-04 
#> Aggregating results
#> Selecting tuning parameters
#> Fitting decay = 1e-04 on full training set
#> # weights:  56 (39 variable)
#> initial  value 833.162911 
#> iter  10 value 407.522712
#> iter  20 value 387.784474
#> iter  30 value 386.971261
#> iter  40 value 386.769896
#> iter  50 value 386.743524
#> final  value 386.743519 
#> converged
BchMk.MLM$finalModel
#> Call:
#> nnet::multinom(formula = .outcome ~ ., data = dat, decay = param$decay)
#> 
#> Coefficients:
#>          (Intercept)         sex     married        age      havejob
#> Formal     -2.883352 -0.29845912  0.20842889 -1.0508652 0.4050999418
#> Informal   -2.829452 -0.07438462 -0.06553534 -0.6294929 0.0008134758
#> L.Both     -3.493449 -0.25150913 -0.29699362 -1.1340836 0.3309852056
#>                 educ political.afl       rural     region fin.intermdiaries
#> Formal    0.09718129     0.2855784  0.54460619 -0.4505575       0.007309791
#> Informal -0.20778309    -0.2617058 -0.07323338  0.1155695      -0.157459459
#> L.Both    0.31616307     0.2857973 -0.43727925  0.1542035       0.141371798
#>          fin.knowldge     income   networth
#> Formal     0.14354111  0.7750757  0.4497748
#> Informal   0.20747504 -2.3438761 -1.2754599
#> L.Both     0.02142886  0.3304522  0.3101215
#> 
#> Residual Deviance: 773.487 
#> AIC: 851.487 
BchMk.MLM$Roc$auc
#> Multi-class area under the curve: 0.7047