logistic <- read.csv("logistic.csv")
attach(logistic)
head(logistic, 5)
The following packagaes are required sjmisc and sjPlot. To create the multinomial models the nnet package needs to be installed.
library(sjmisc)
library(sjPlot)
library(nnet)
library(wakefield)
library(dplyr)
library(nnet)
library(caTools)
library(ROCR)
library(stargazer)
library(dplyr)
library(nnet)
library(caTools)
library(ROCR)
library(stargazer)
library(ISLR)
library(ISLR2)
library(MASS)
library(caret)
library(splines)
library(splines2)
library(pROC)
library(ISLR)
library(ISLR2)
library(MASS)
library(caret)
library(splines)
library(splines2)
library(pROC)
library(randomForest)
library(rpart)
library(rpart.plot)
library(rattle)
library(ISLR2)
library(MASS)
library(caret)
library(splines)
library(pROC)
library(rattle)
library(rpart)
library(party)
library(partykit)
library(ggplot2)
logistic$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. <- factor(logistic$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year., levels = c(0,1),
labels = c("No", "Yes"))
frq(logistic, Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. <categorical>
# total N=439 valid N=439 mean=1.15 sd=0.36
Value | N | Raw % | Valid % | Cum. %
--------------------------------------
No | 372 | 84.74 | 84.74 | 84.74
Yes | 67 | 15.26 | 15.26 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
logistic$What.is.your.age. <- as.factor(logistic$What.is.your.age.)
logistic$What.is.the.gender.of.the.proprietor.of.the.business. <- as.factor(logistic$What.is.the.gender.of.the.proprietor.of.the.business.)
logistic$Location.type <- as.factor(logistic$Location.type)
logistic$What.is.the.highest.level.of.formal.education.that.you.have.completed. <- as.factor(logistic$What.is.the.highest.level.of.formal.education.that.you.have.completed.)
logistic$How.many.employees.does.your.business.have. <- as.factor(logistic$How.many.employees.does.your.business.have.)
logistic$Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan.... <- as.factor(logistic$Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....)
logistic$What.type.of.healthcare.services.does.your.business.primarily.offer. <- as.factor(logistic$What.type.of.healthcare.services.does.your.business.primarily.offer.)
logistic$Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures. <- as.factor(logistic$Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.)
logistic$Have.you.estimated.your.annual.turnover.for.the.past.year. <- as.factor(logistic$Have.you.estimated.your.annual.turnover.for.the.past.year.)
logistic$On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan. <- as.factor(logistic$On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.)
logistic$Do.you.maintain.a.business.account.with.a.formal.financial.institution. <-as.factor(logistic$Do.you.maintain.a.business.account.with.a.formal.financial.institution.)
logistic$How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds. <- as.factor(logistic$How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.)
frq(logistic, What.is.the.highest.level.of.formal.education.that.you.have.completed.)
What.is.the.highest.level.of.formal.education.that.you.have.completed. <categorical>
# total N=439 valid N=439 mean=2.00 sd=0.07
Value | N | Raw % | Valid % | Cum. %
------------------------------------------
Secondary | 2 | 0.46 | 0.46 | 0.46
Tertiary | 437 | 99.54 | 99.54 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, What.is.your.age.)
What.is.your.age. <categorical>
# total N=439 valid N=439 mean=2.23 sd=0.82
Value | N | Raw % | Valid % | Cum. %
-----------------------------------------
18-30 | 73 | 16.63 | 16.63 | 16.63
30-40 | 226 | 51.48 | 51.48 | 68.11
40-50 | 105 | 23.92 | 23.92 | 92.03
Above 50 | 35 | 7.97 | 7.97 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, Location.type)
Location.type <categorical>
# total N=439 valid N=439 mean=2.29 sd=0.95
Value | N | Raw % | Valid % | Cum. %
-------------------------------------------
Peri-urban | 153 | 34.85 | 34.85 | 34.85
Rural | 5 | 1.14 | 1.14 | 35.99
Urban | 281 | 64.01 | 64.01 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, How.many.employees.does.your.business.have.)
How.many.employees.does.your.business.have. <categorical>
# total N=439 valid N=439 mean=2.45 sd=0.74
Value | N | Raw % | Valid % | Cum. %
---------------------------------------------------------
Medium Business (50-249) | 5 | 1.14 | 1.14 | 1.14
Micro Business (2-9) | 292 | 66.51 | 66.51 | 67.65
Small Business (10-49) | 81 | 18.45 | 18.45 | 86.10
Solo Entrepreneur (1) | 61 | 13.90 | 13.90 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....)
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan.... <categorical>
# total N=439 valid N=439 mean=1.79 sd=0.94
Value | N | Raw % | Valid % | Cum. %
--------------------------------------------------
No | 252 | 57.40 | 57.40 | 57.40
Refused to answer | 29 | 6.61 | 6.61 | 64.01
Yes | 158 | 35.99 | 35.99 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic,What.type.of.healthcare.services.does.your.business.primarily.offer.)
What.type.of.healthcare.services.does.your.business.primarily.offer. <categorical>
# total N=439 valid N=439 mean=5.65 sd=2.12
Value | N | Raw % | Valid % | Cum. %
-------------------------------------------------------------------
Dental clinic | 5 | 1.14 | 1.14 | 1.14
Health center | 1 | 0.23 | 0.23 | 1.37
Hospital | 40 | 9.11 | 9.11 | 10.48
Medical Clinic | 182 | 41.46 | 41.46 | 51.94
Medical Clinic | 14 | 3.19 | 3.19 | 55.13
Standalone diagnostic center | 15 | 3.42 | 3.42 | 58.54
Standalone diagnostic center | 1 | 0.23 | 0.23 | 58.77
Standalone pharmacy | 173 | 39.41 | 39.41 | 98.18
Standalone pharmacy | 7 | 1.59 | 1.59 | 99.77
Therapy center (counseling center) | 1 | 0.23 | 0.23 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.)
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures. <categorical>
# total N=439 valid N=439 mean=1.83 sd=0.37
Value | N | Raw % | Valid % | Cum. %
--------------------------------------
No | 73 | 16.63 | 16.63 | 16.63
Yes | 366 | 83.37 | 83.37 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, Have.you.estimated.your.annual.turnover.for.the.past.year.)
Have.you.estimated.your.annual.turnover.for.the.past.year. <categorical>
# total N=439 valid N=439 mean=1.55 sd=0.50
Value | N | Raw % | Valid % | Cum. %
--------------------------------------
No | 196 | 44.65 | 44.65 | 44.65
Yes | 243 | 55.35 | 55.35 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan. <categorical>
# total N=439 valid N=439 mean=2.06 sd=1.73
Value | N | Raw % | Valid % | Cum. %
------------------------------------------------------
| 281 | 64.01 | 64.01 | 64.01
Challenging | 25 | 5.69 | 5.69 | 69.70
Easy | 74 | 16.86 | 16.86 | 86.56
Easy | 1 | 0.23 | 0.23 | 86.79
Extremely Challenging | 9 | 2.05 | 2.05 | 88.84
Neutral | 39 | 8.88 | 8.88 | 97.72
Very easy | 10 | 2.28 | 2.28 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, Do.you.maintain.a.business.account.with.a.formal.financial.institution.)
Do.you.maintain.a.business.account.with.a.formal.financial.institution. <categorical>
# total N=439 valid N=439 mean=1.78 sd=0.42
Value | N | Raw % | Valid % | Cum. %
--------------------------------------
No | 98 | 22.32 | 22.32 | 22.32
Yes | 341 | 77.68 | 77.68 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds. <categorical>
# total N=439 valid N=439 mean=3.66 sd=1.66
Value | N | Raw % | Valid % | Cum. %
----------------------------------------------------
Daily | 57 | 12.98 | 12.98 | 12.98
Monthly | 97 | 22.10 | 22.10 | 35.08
Never | 15 | 3.42 | 3.42 | 38.50
No specific pattern | 94 | 21.41 | 21.41 | 59.91
Rarely | 122 | 27.79 | 27.79 | 87.70
Weekly | 54 | 12.30 | 12.30 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
frq(logistic, How.long.has.your.business.been.in.operation..months..)
How.long.has.your.business.been.in.operation..months.. <integer>
# total N=439 valid N=439 mean=69.96 sd=71.20
Value | N | Raw % | Valid % | Cum. %
-------------------------------------
3 | 5 | 1.14 | 1.14 | 1.14
4 | 2 | 0.46 | 0.46 | 1.59
5 | 3 | 0.68 | 0.68 | 2.28
6 | 2 | 0.46 | 0.46 | 2.73
7 | 4 | 0.91 | 0.91 | 3.64
8 | 2 | 0.46 | 0.46 | 4.10
9 | 4 | 0.91 | 0.91 | 5.01
10 | 5 | 1.14 | 1.14 | 6.15
11 | 1 | 0.23 | 0.23 | 6.38
12 | 24 | 5.47 | 5.47 | 11.85
13 | 1 | 0.23 | 0.23 | 12.07
14 | 2 | 0.46 | 0.46 | 12.53
15 | 4 | 0.91 | 0.91 | 13.44
16 | 2 | 0.46 | 0.46 | 13.90
18 | 5 | 1.14 | 1.14 | 15.03
20 | 2 | 0.46 | 0.46 | 15.49
21 | 1 | 0.23 | 0.23 | 15.72
24 | 50 | 11.39 | 11.39 | 27.11
25 | 1 | 0.23 | 0.23 | 27.33
26 | 4 | 0.91 | 0.91 | 28.25
28 | 4 | 0.91 | 0.91 | 29.16
30 | 3 | 0.68 | 0.68 | 29.84
32 | 3 | 0.68 | 0.68 | 30.52
34 | 1 | 0.23 | 0.23 | 30.75
35 | 1 | 0.23 | 0.23 | 30.98
36 | 66 | 15.03 | 15.03 | 46.01
38 | 1 | 0.23 | 0.23 | 46.24
40 | 3 | 0.68 | 0.68 | 46.92
41 | 1 | 0.23 | 0.23 | 47.15
42 | 2 | 0.46 | 0.46 | 47.61
48 | 39 | 8.88 | 8.88 | 56.49
50 | 1 | 0.23 | 0.23 | 56.72
52 | 1 | 0.23 | 0.23 | 56.95
54 | 1 | 0.23 | 0.23 | 57.18
56 | 6 | 1.37 | 1.37 | 58.54
58 | 1 | 0.23 | 0.23 | 58.77
60 | 27 | 6.15 | 6.15 | 64.92
67 | 1 | 0.23 | 0.23 | 65.15
70 | 1 | 0.23 | 0.23 | 65.38
72 | 35 | 7.97 | 7.97 | 73.35
74 | 1 | 0.23 | 0.23 | 73.58
76 | 1 | 0.23 | 0.23 | 73.80
78 | 1 | 0.23 | 0.23 | 74.03
80 | 1 | 0.23 | 0.23 | 74.26
84 | 11 | 2.51 | 2.51 | 76.77
90 | 3 | 0.68 | 0.68 | 77.45
94 | 1 | 0.23 | 0.23 | 77.68
96 | 15 | 3.42 | 3.42 | 81.09
108 | 2 | 0.46 | 0.46 | 81.55
110 | 1 | 0.23 | 0.23 | 81.78
120 | 28 | 6.38 | 6.38 | 88.15
132 | 4 | 0.91 | 0.91 | 89.07
144 | 2 | 0.46 | 0.46 | 89.52
156 | 1 | 0.23 | 0.23 | 89.75
166 | 1 | 0.23 | 0.23 | 89.98
168 | 1 | 0.23 | 0.23 | 90.21
180 | 6 | 1.37 | 1.37 | 91.57
183 | 1 | 0.23 | 0.23 | 91.80
192 | 2 | 0.46 | 0.46 | 92.26
216 | 2 | 0.46 | 0.46 | 92.71
228 | 3 | 0.68 | 0.68 | 93.39
240 | 14 | 3.19 | 3.19 | 96.58
264 | 2 | 0.46 | 0.46 | 97.04
276 | 4 | 0.91 | 0.91 | 97.95
288 | 2 | 0.46 | 0.46 | 98.41
312 | 1 | 0.23 | 0.23 | 98.63
324 | 2 | 0.46 | 0.46 | 99.09
342 | 1 | 0.23 | 0.23 | 99.32
360 | 1 | 0.23 | 0.23 | 99.54
396 | 1 | 0.23 | 0.23 | 99.77
480 | 1 | 0.23 | 0.23 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
str(logistic)
'data.frame': 439 obs. of 15 variables:
$ Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 2 2 1 1 1 ...
$ What.is.your.age. : Factor w/ 4 levels "18-30","30-40",..: 2 2 2 2 3 1 4 1 2 3 ...
$ A7.What.is.your.gender. : chr "Female" "Male" "Male" "Male" ...
$ What.is.the.gender.of.the.proprietor.of.the.business. : Factor w/ 2 levels "Female","Male": 1 1 2 2 2 2 2 1 2 2 ...
$ Location.type : Factor w/ 3 levels "Peri-urban","Rural",..: 1 3 1 1 1 1 1 1 3 3 ...
$ What.is.the.highest.level.of.formal.education.that.you.have.completed. : Factor w/ 2 levels "Secondary","Tertiary": 2 2 2 2 2 2 2 2 2 2 ...
$ How.long.has.your.business.been.in.operation..months.. : int 14 36 36 30 12 72 396 11 120 96 ...
$ How.many.employees.does.your.business.have. : Factor w/ 4 levels "Medium Business (50-249)",..: 2 2 3 2 2 2 2 2 2 2 ...
$ Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....: Factor w/ 3 levels "No","Refused to answer",..: 1 3 1 1 1 3 3 1 3 3 ...
$ What.type.of.healthcare.services.does.your.business.primarily.offer. : Factor w/ 10 levels "Dental clinic",..: 8 8 4 1 8 4 4 8 4 4 ...
$ Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures. : Factor w/ 2 levels "No","Yes": 2 2 2 2 2 1 1 2 2 2 ...
$ Have.you.estimated.your.annual.turnover.for.the.past.year. : Factor w/ 2 levels "No","Yes": 2 2 2 2 2 2 2 2 2 1 ...
$ On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan. : Factor w/ 7 levels "","Challenging",..: 1 2 1 1 1 7 3 1 6 6 ...
$ Do.you.maintain.a.business.account.with.a.formal.financial.institution. : Factor w/ 2 levels "No","Yes": 1 1 2 2 1 1 2 2 2 2 ...
$ How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds. : Factor w/ 6 levels "Daily","Monthly",..: 5 4 5 4 5 5 6 6 2 5 ...
GLM<- glm(Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.~.,data=logistic,family="binomial")
GLM
Call: glm(formula = Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. ~
., family = "binomial", data = logistic)
Coefficients:
(Intercept)
-30.971659
What.is.your.age.30-40
-0.997033
What.is.your.age.40-50
-1.123371
What.is.your.age.Above 50
-0.824448
A7.What.is.your.gender.Male
0.463957
What.is.the.gender.of.the.proprietor.of.the.business.Male
0.029266
Location.typeRural
-0.590409
Location.typeUrban
-1.045347
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary
-2.327602
How.long.has.your.business.been.in.operation..months..
0.003309
How.many.employees.does.your.business.have.Micro Business (2-9)
15.669309
How.many.employees.does.your.business.have.Small Business (10-49)
14.544568
How.many.employees.does.your.business.have.Solo Entrepreneur (1)
15.175254
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer
-13.820397
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes
5.019720
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center
33.971395
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital
13.530612
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
14.897154
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
13.303194
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
14.622921
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
2.927602
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
16.029328
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
15.045247
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center)
35.077079
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes
-1.185516
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes
-0.362410
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging
-0.952810
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
0.626968
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
19.461982
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging
-1.841060
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral
-0.529131
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy
NA
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes
-0.103341
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly
-0.190904
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never
-0.026838
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern
-0.642816
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely
-1.376474
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly
0.374125
Degrees of Freedom: 438 Total (i.e. Null); 402 Residual
Null Deviance: 375.1
Residual Deviance: 168.7 AIC: 242.7
summary(GLM)
Call:
glm(formula = Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. ~
., family = "binomial", data = logistic)
Coefficients: (1 not defined because of singularities)
Estimate
(Intercept) -3.097e+01
What.is.your.age.30-40 -9.970e-01
What.is.your.age.40-50 -1.123e+00
What.is.your.age.Above 50 -8.244e-01
A7.What.is.your.gender.Male 4.640e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male 2.927e-02
Location.typeRural -5.904e-01
Location.typeUrban -1.045e+00
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary -2.328e+00
How.long.has.your.business.been.in.operation..months.. 3.309e-03
How.many.employees.does.your.business.have.Micro Business (2-9) 1.567e+01
How.many.employees.does.your.business.have.Small Business (10-49) 1.454e+01
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 1.518e+01
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer -1.382e+01
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 5.020e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 3.397e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 1.353e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 1.490e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 1.330e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 1.462e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 2.928e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 1.603e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 1.505e+01
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 3.508e+01
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes -1.186e+00
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes -3.624e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging -9.528e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 6.270e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 1.946e+01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging -1.841e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral -5.291e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy NA
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes -1.033e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly -1.909e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never -2.684e-02
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern -6.428e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely -1.376e+00
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 3.741e-01
Std. Error
(Intercept) 3.614e+03
What.is.your.age.30-40 6.537e-01
What.is.your.age.40-50 7.667e-01
What.is.your.age.Above 50 8.703e-01
A7.What.is.your.gender.Male 6.589e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male 7.119e-01
Location.typeRural 1.566e+00
Location.typeUrban 4.752e-01
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary 2.875e+00
How.long.has.your.business.been.in.operation..months.. 3.594e-03
How.many.employees.does.your.business.have.Micro Business (2-9) 2.400e+03
How.many.employees.does.your.business.have.Small Business (10-49) 2.400e+03
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 2.400e+03
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer 1.051e+03
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 1.102e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 7.060e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 7.060e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 2.703e+03
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 7.060e+03
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes 5.202e-01
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes 4.712e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging 1.060e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 9.144e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 6.523e+03
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging 1.622e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral 9.952e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy NA
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 5.984e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly 7.000e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never 1.966e+00
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern 7.398e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely 7.098e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 8.428e-01
z value
(Intercept) -0.009
What.is.your.age.30-40 -1.525
What.is.your.age.40-50 -1.465
What.is.your.age.Above 50 -0.947
A7.What.is.your.gender.Male 0.704
What.is.the.gender.of.the.proprietor.of.the.business.Male 0.041
Location.typeRural -0.377
Location.typeUrban -2.200
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary -0.810
How.long.has.your.business.been.in.operation..months.. 0.921
How.many.employees.does.your.business.have.Micro Business (2-9) 0.007
How.many.employees.does.your.business.have.Small Business (10-49) 0.006
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 0.006
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer -0.013
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 4.555
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 0.005
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 0.005
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 0.006
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 0.005
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 0.005
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 0.000
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 0.006
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 0.006
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 0.005
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes -2.279
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes -0.769
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging -0.899
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 0.686
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 0.003
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging -1.135
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral -0.532
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy NA
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes -0.173
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly -0.273
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never -0.014
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern -0.869
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely -1.939
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 0.444
Pr(>|z|)
(Intercept) 0.9932
What.is.your.age.30-40 0.1272
What.is.your.age.40-50 0.1428
What.is.your.age.Above 50 0.3435
A7.What.is.your.gender.Male 0.4813
What.is.the.gender.of.the.proprietor.of.the.business.Male 0.9672
Location.typeRural 0.7061
Location.typeUrban 0.0278
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary 0.4181
How.long.has.your.business.been.in.operation..months.. 0.3572
How.many.employees.does.your.business.have.Micro Business (2-9) 0.9948
How.many.employees.does.your.business.have.Small Business (10-49) 0.9952
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 0.9950
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer 0.9895
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 5.23e-06
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 0.9962
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 0.9960
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 0.9956
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 0.9961
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 0.9957
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 0.9997
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 0.9953
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 0.9956
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 0.9960
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes 0.0227
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes 0.4418
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging 0.3688
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 0.4929
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 0.9976
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging 0.2565
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral 0.5950
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy NA
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 0.8629
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly 0.7851
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never 0.9891
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern 0.3849
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely 0.0525
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 0.6571
(Intercept)
What.is.your.age.30-40
What.is.your.age.40-50
What.is.your.age.Above 50
A7.What.is.your.gender.Male
What.is.the.gender.of.the.proprietor.of.the.business.Male
Location.typeRural
Location.typeUrban *
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary
How.long.has.your.business.been.in.operation..months..
How.many.employees.does.your.business.have.Micro Business (2-9)
How.many.employees.does.your.business.have.Small Business (10-49)
How.many.employees.does.your.business.have.Solo Entrepreneur (1)
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes ***
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center)
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes *
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely .
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 375.10 on 438 degrees of freedom
Residual deviance: 168.66 on 402 degrees of freedom
AIC: 242.66
Number of Fisher Scoring iterations: 17
library(stargazer)
stargazer(GLM,type="text")
===========================================================================================================================================================================================================================
Dependent variable:
--------------------------------------------------------------------------------
Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
What.is.your.age.30-40 -0.997
(0.654)
What.is.your.age.40-50 -1.123
(0.767)
What.is.your.age.Above 50 -0.824
(0.870)
A7.What.is.your.gender.Male 0.464
(0.659)
What.is.the.gender.of.the.proprietor.of.the.business.Male 0.029
(0.712)
Location.typeRural -0.590
(1.566)
Location.typeUrban -1.045**
(0.475)
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary -2.328
(2.875)
How.long.has.your.business.been.in.operation..months.. 0.003
(0.004)
How.many.employees.does.your.business.have.Micro Business (2-9) 15.669
(2,400.119)
How.many.employees.does.your.business.have.Small Business (10-49) 14.545
(2,400.119)
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 15.175
(2,400.119)
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer -13.820
(1,050.564)
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 5.020***
(1.102)
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 33.971
(7,060.361)
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 13.531
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 14.897
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 13.303
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 14.623
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center 2.928
(7,060.361)
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 16.029
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 15.045
(2,702.569)
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 35.077
(7,060.361)
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes -1.186**
(0.520)
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes -0.362
(0.471)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging -0.953
(1.060)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 0.627
(0.914)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 19.462
(6,522.639)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging -1.841
(1.622)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral -0.529
(0.995)
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes -0.103
(0.598)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly -0.191
(0.700)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never -0.027
(1.966)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern -0.643
(0.740)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely -1.376*
(0.710)
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 0.374
(0.843)
Constant -30.972
(3,614.479)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Observations 439
Log Likelihood -84.328
Akaike Inf. Crit. 242.656
===========================================================================================================================================================================================================================
Note: *p<0.1; **p<0.05; ***p<0.01
Let us make use of set.seed() so that if you partition the data set, you don’t get different train and test data set.
ind <- sample(2, nrow(logistic),
replace = TRUE,
prob = c(0.7, 0.3))
training <- logistic[ind==1,]
testing <- logistic[ind ==2,]
From the code above, we can see that the training data set has 315 observations with 15 variables while the testing data set has 124 observations with 15 variables
## Load the following library
library(nnet) ### nnet stands for neuro network
One most important we must tell the system is the reference level. Out of levels 0 and 1, what is our reference level. In this case, our reference level will be the “Yes” category
logistic$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. <- relevel(logistic$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year., ref = "Yes")
In the command below, we are going to use all other variables as independent variables
#### the model
mymodel <- multinom(Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.~.,data = training)
# weights: 39 (38 variable)
initial value 212.796184
iter 10 value 68.235754
iter 20 value 61.840491
iter 30 value 61.590078
iter 40 value 61.552008
iter 50 value 61.549804
final value 61.549797
converged
### Summary of the model
summary(mymodel)
Call:
multinom(formula = Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. ~
., data = training)
Coefficients:
Values
(Intercept) -24.476401859
What.is.your.age.30-40 -0.941822886
What.is.your.age.40-50 -1.807104765
What.is.your.age.Above 50 -0.551027232
A7.What.is.your.gender.Male -0.204602827
What.is.the.gender.of.the.proprietor.of.the.business.Male 0.262706416
Location.typeRural -0.466057492
Location.typeUrban -2.277636772
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary -1.596350060
How.long.has.your.business.been.in.operation..months.. 0.006856446
How.many.employees.does.your.business.have.Micro Business (2-9) 10.343706296
How.many.employees.does.your.business.have.Small Business (10-49) 9.147553934
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 8.621815861
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer -44.600772025
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 9.326875857
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 0.000000000
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 11.942255883
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 12.613387768
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 11.327956019
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center -40.997688818
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center -0.519297908
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 14.959962717
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 11.741098250
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 0.000000000
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes -0.850650126
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes -1.458444475
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging -4.929844397
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy -3.138812141
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 29.720916392
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging -5.035505662
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral -4.014821852
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy -3.275056483
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 0.393809771
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly -0.156081799
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never -0.133647045
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern -0.474503969
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely -0.897204511
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 1.597320069
Std. Err.
(Intercept) 1.995215e+00
What.is.your.age.30-40 7.567803e-01
What.is.your.age.40-50 8.880363e-01
What.is.your.age.Above 50 1.098477e+00
A7.What.is.your.gender.Male 9.419864e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male 9.593197e-01
Location.typeRural 1.632579e+00
Location.typeUrban 7.110527e-01
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary 2.699992e+00
How.long.has.your.business.been.in.operation..months.. 4.759671e-03
How.many.employees.does.your.business.have.Micro Business (2-9) 7.082515e-01
How.many.employees.does.your.business.have.Small Business (10-49) 1.017452e+00
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 9.327603e-01
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer NaN
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 8.309435e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 1.277149e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 6.797745e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 1.048619e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 8.274331e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 1.895225e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 1.731163e-14
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes 6.134385e-01
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes 6.565125e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging 7.220233e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 5.695997e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 1.030341e-16
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging 1.522534e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral 6.379476e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy 9.898820e-01
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 7.595512e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly 8.293837e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never 1.809878e+00
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern 8.867888e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely 8.366456e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 1.091585e+00
Residual Deviance: 123.0996
AIC: 193.0996
From the results above, we estimated the model with all 21 independent variable, therefore we have to check which variable is statistically significant. We therefore have to conduct a two-tailed Z-test.
### 2-tailed z-test
z <- summary(mymodel)$coefficients/summary(mymodel)$standard.errors
p <- (1-pnorm(abs(z),0,1)) *2
p
(Intercept)
0.000000e+00
What.is.your.age.30-40
2.133109e-01
What.is.your.age.40-50
4.185645e-02
What.is.your.age.Above 50
6.159290e-01
A7.What.is.your.gender.Male
8.280497e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male
7.842025e-01
Location.typeRural
7.752816e-01
Location.typeUrban
1.359145e-03
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary
5.543580e-01
How.long.has.your.business.been.in.operation..months..
1.497177e-01
How.many.employees.does.your.business.have.Micro Business (2-9)
0.000000e+00
How.many.employees.does.your.business.have.Small Business (10-49)
0.000000e+00
How.many.employees.does.your.business.have.Solo Entrepreneur (1)
0.000000e+00
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer
NaN
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
5.825027e-10
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center)
1.000000e+00
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes
1.655358e-01
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes
2.631690e-02
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging
8.621548e-12
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
3.576984e-08
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
0.000000e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging
9.419367e-04
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral
3.107039e-10
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy
9.378637e-04
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes
6.041255e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly
8.507276e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never
9.411352e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern
5.925937e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely
2.835480e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly
1.433844e-01
From the results above, we can drop variable that are insignificant. In other words, such variable are contributing anything to the model. For instance, we can drop variables like MLTV, Width, Min, Mode, Nmax, Nzeros and Tendency. We can now run the model again.
mymodel <- multinom(Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.~.,data = training)
# weights: 39 (38 variable)
initial value 212.796184
iter 10 value 68.235754
iter 20 value 61.840491
iter 30 value 61.590078
iter 40 value 61.552008
iter 50 value 61.549804
final value 61.549797
converged
summary(mymodel)
Call:
multinom(formula = Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. ~
., data = training)
Coefficients:
Values
(Intercept) -24.476401859
What.is.your.age.30-40 -0.941822886
What.is.your.age.40-50 -1.807104765
What.is.your.age.Above 50 -0.551027232
A7.What.is.your.gender.Male -0.204602827
What.is.the.gender.of.the.proprietor.of.the.business.Male 0.262706416
Location.typeRural -0.466057492
Location.typeUrban -2.277636772
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary -1.596350060
How.long.has.your.business.been.in.operation..months.. 0.006856446
How.many.employees.does.your.business.have.Micro Business (2-9) 10.343706296
How.many.employees.does.your.business.have.Small Business (10-49) 9.147553934
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 8.621815861
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer -44.600772025
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 9.326875857
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center 0.000000000
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 11.942255883
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 12.613387768
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 11.327956019
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center -40.997688818
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center -0.519297908
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 14.959962717
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 11.741098250
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 0.000000000
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes -0.850650126
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes -1.458444475
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging -4.929844397
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy -3.138812141
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 29.720916392
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging -5.035505662
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral -4.014821852
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy -3.275056483
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 0.393809771
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly -0.156081799
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never -0.133647045
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern -0.474503969
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely -0.897204511
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 1.597320069
Std. Err.
(Intercept) 1.995215e+00
What.is.your.age.30-40 7.567803e-01
What.is.your.age.40-50 8.880363e-01
What.is.your.age.Above 50 1.098477e+00
A7.What.is.your.gender.Male 9.419864e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male 9.593197e-01
Location.typeRural 1.632579e+00
Location.typeUrban 7.110527e-01
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary 2.699992e+00
How.long.has.your.business.been.in.operation..months.. 4.759671e-03
How.many.employees.does.your.business.have.Micro Business (2-9) 7.082515e-01
How.many.employees.does.your.business.have.Small Business (10-49) 1.017452e+00
How.many.employees.does.your.business.have.Solo Entrepreneur (1) 9.327603e-01
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer NaN
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes 8.309435e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital 1.277149e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 6.797745e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic 1.048619e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 8.274331e-01
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy 1.895225e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center) 1.731163e-14
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes 6.134385e-01
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes 6.565125e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging 7.220233e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 5.695997e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy 1.030341e-16
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging 1.522534e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral 6.379476e-01
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy 9.898820e-01
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes 7.595512e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly 8.293837e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never 1.809878e+00
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern 8.867888e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely 8.366456e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly 1.091585e+00
Residual Deviance: 123.0996
AIC: 193.0996
z <- summary(mymodel)$coefficients/summary(mymodel)$standard.errors
p <- (1-pnorm(abs(z),0,1)) *2
p
(Intercept)
0.000000e+00
What.is.your.age.30-40
2.133109e-01
What.is.your.age.40-50
4.185645e-02
What.is.your.age.Above 50
6.159290e-01
A7.What.is.your.gender.Male
8.280497e-01
What.is.the.gender.of.the.proprietor.of.the.business.Male
7.842025e-01
Location.typeRural
7.752816e-01
Location.typeUrban
1.359145e-03
What.is.the.highest.level.of.formal.education.that.you.have.completed.Tertiary
5.543580e-01
How.long.has.your.business.been.in.operation..months..
1.497177e-01
How.many.employees.does.your.business.have.Micro Business (2-9)
0.000000e+00
How.many.employees.does.your.business.have.Small Business (10-49)
0.000000e+00
How.many.employees.does.your.business.have.Solo Entrepreneur (1)
0.000000e+00
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Refused to answer
NaN
Has.your.business.previously.taken.any.form.of.loan...e.g...bank.loan..micro.financial.institution.loan..digital.loan....Yes
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Health center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Hospital
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Medical Clinic
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone diagnostic center
NaN
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
0.000000e+00
What.type.of.healthcare.services.does.your.business.primarily.offer.Standalone pharmacy
5.825027e-10
What.type.of.healthcare.services.does.your.business.primarily.offer.Therapy center (counseling center)
1.000000e+00
Do.you.use.an.information.system.to.keep.track.of.your.business.income.and.expenditures.Yes
1.655358e-01
Have.you.estimated.your.annual.turnover.for.the.past.year.Yes
2.631690e-02
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Challenging
8.621548e-12
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
3.576984e-08
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Easy
0.000000e+00
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Extremely Challenging
9.419367e-04
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Neutral
3.107039e-10
On.a.scale.of.1.to.5..what.was.your.experience.in.accessing.the.loan.Very easy
9.378637e-04
Do.you.maintain.a.business.account.with.a.formal.financial.institution.Yes
6.041255e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Monthly
8.507276e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Never
9.411352e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.No specific pattern
5.925937e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Rarely
2.835480e-01
How.frequently.do.you.encounter.financial.situations.where.you.require.immediate.access.to.funds.Weekly
1.433844e-01
##Confusion Matrix ### Misclassification Error In this step we will create confusion matrix for the model, for both training and test data set. We shall of calculate the misclssification error once again for both training and test data set
Remember we created the model for variables that are only significant. We removed variables that are not significant from our model. We will therefore use our preferred model to create the confusion matrix
### Confusion matrix for the training data set
p <- predict(mymodel, training)
head(p)
[1] No No Yes Yes No Yes
Levels: No Yes
The results shows the classification of first six participants. We can now compare with actual patient in our training data set
head(training$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
[1] No No Yes Yes No Yes
Levels: No Yes
confusion_matrix <- table(p, training$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
confusion_matrix
p No Yes
No 242 19
Yes 14 32
Using the results above, we can calculate the accuracy rate of our model; ### Correct classification
sum(diag(confusion_matrix))/sum(confusion_matrix)
[1] 0.8925081
The model has 90.30498% correct classification
1-sum(diag(confusion_matrix))/sum(confusion_matrix)
[1] 0.1074919
The model has 7.619048% misclassification.
attach(training)
confusionMatrix(p, Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year., positive = "Yes")
Confusion Matrix and Statistics
Reference
Prediction No Yes
No 242 19
Yes 14 32
Accuracy : 0.8925
95% CI : (0.8524, 0.9248)
No Information Rate : 0.8339
P-Value [Acc > NIR] : 0.002466
Kappa : 0.5962
Mcnemar's Test P-Value : 0.486234
Sensitivity : 0.6275
Specificity : 0.9453
Pos Pred Value : 0.6957
Neg Pred Value : 0.9272
Prevalence : 0.1661
Detection Rate : 0.1042
Detection Prevalence : 0.1498
Balanced Accuracy : 0.7864
'Positive' Class : Yes
p1 <- predict(mymodel, testing)
head(p1)
[1] No No No No No No
Levels: No Yes
head(testing$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
[1] No No No No No No
Levels: No Yes
confusion_matrix1 <- table(p1, testing$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
confusion_matrix1
p1 No Yes
No 110 10
Yes 6 6
sum(diag(confusion_matrix1))/sum(confusion_matrix1)
[1] 0.8787879
1- sum(diag(confusion_matrix1))/sum(confusion_matrix1)
[1] 0.1212121
attach(testing)
confusionMatrix(p1, Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year., positive = "Yes")
Confusion Matrix and Statistics
Reference
Prediction No Yes
No 110 10
Yes 6 6
Accuracy : 0.8788
95% CI : (0.8106, 0.9291)
No Information Rate : 0.8788
P-Value [Acc > NIR] : 0.5661
Kappa : 0.3623
Mcnemar's Test P-Value : 0.4533
Sensitivity : 0.37500
Specificity : 0.94828
Pos Pred Value : 0.50000
Neg Pred Value : 0.91667
Prevalence : 0.12121
Detection Rate : 0.04545
Detection Prevalence : 0.09091
Balanced Accuracy : 0.66164
'Positive' Class : Yes
In the context of multinomial logistic regression, accuracy and sensitivity are both important metrics for evaluating the performance of the model. Accuracy represents the overall correctness of the model’s predictions across all categories or classes. It measures the proportion of correctly predicted instances out of the total instances in the data set. While accuracy is a useful metric, especially when classes are balanced, it may not provide a complete picture of model performance when dealing with imbalanced datasets or when different classes have varying levels of importance.
On the other hand, sensitivity, also known as the true positive rate or recall, focuses on the model’s ability to correctly identify instances from a specific class. It measures the proportion of true positives (correctly predicted instances of a particular class) out of all actual instances belonging to that class. Sensitivity is particularly important when dealing with imbalanced datasets or when certain classes are more critical to identify correctly than others, such as in medical diagnosis.
In summary, while accuracy gives an overall view of model performance, sensitivity provides insights into the model’s ability to correctly detect specific classes, making it a valuable metric when dealing with imbalanced datasets or when certain classes have greater significance in the application. Both metrics should be considered in the context of the problem you’re addressing to fully assess the effectiveness of your multinomial logistic regression model.
Suppose we want to know how participants were classified as ether “Yes” or “No” category in the training data set, we can use the command below
frq(training, Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year. <categorical>
# total N=307 valid N=307 mean=1.17 sd=0.37
Value | N | Raw % | Valid % | Cum. %
--------------------------------------
No | 256 | 83.39 | 83.39 | 83.39
Yes | 51 | 16.61 | 16.61 | 100.00
<NA> | 0 | 0.00 | <NA> | <NA>
From the training data, 273 were found to be in the “No” category, and 42 of the participants were in the “Yes” category.
n <- table(training$Have.you.ever.taken.a.loan.through.digital.or.online.platforms.in.the.past.year.)
n/sum(n)*100
No Yes
83.38762 16.61238
From the data, 86.667% participants were in the “No” category and 13.333% were in the “Yes” category.
confusion_matrix/colSums(confusion_matrix)
p No Yes
No 0.94531250 0.07421875
Yes 0.27450980 0.62745098
From the results above, the model is 95.6.13% classification for No category , 71.42% correct classification for Yes category In other words, the model is doing good in classifying No category as compared to Yes category.
confusion_matrix1/colSums(confusion_matrix1)
p1 No Yes
No 0.9482759 0.0862069
Yes 0.3750000 0.3750000
From the results above, the model predicts 89.89% correct classification for No participants, 24%% correct classification for Yes patients. In other words, the model is doing good in classifying No as comapred to classifying Yes category.