0% found this document useful (0 votes)
61 views

Saggrahakmeans.R: "Ggplot2" "Dplyr"

The document summarizes survey data from 358 respondents about their experiences with a microfinance institution called Saggraha MFI. It provides summary statistics like minimum, maximum, mean and quartiles for 28 survey questions related to the impact of loans on respondents' productivity, quality of life, income, and perceptions of the MFI's services. It then selects a subset of the survey questions for further analysis.

Uploaded by

Himanshu Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Saggrahakmeans.R: "Ggplot2" "Dplyr"

The document summarizes survey data from 358 respondents about their experiences with a microfinance institution called Saggraha MFI. It provides summary statistics like minimum, maximum, mean and quartiles for 28 survey questions related to the impact of loans on respondents' productivity, quality of life, income, and perceptions of the MFI's services. It then selects a subset of the survey questions for further analysis.

Uploaded by

Himanshu Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

SaggrahaKMeans.

R
him26

2021-08-20
library("ggplot2")
library("dplyr")

##
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':


##
## filter, lag

## The following objects are masked from 'package:base':


##
## intersect, setdiff, setequal, union

library("ggfortify")

library(readxl)
data1 <-
read_excel("C:/Users/him26/Downloads/Saggraha/SaggrahaDataClustering.xlsm")
View(data1)
summary(data1)

## 1. Survey Number: 4. Borrower Name: 5. Branch Name 6. Customer Id:

## Min. : 1.00 Length:358 Length:358 Length:358

## 1st Qu.: 90.25 Class :character Class :character Class :character

## Median :179.50 Mode :character Mode :character Mode :character

## Mean :179.50

## 3rd Qu.:268.75

## Max. :358.00

## 7. Loan Id: 9. Respondent Name: 10. Household head name:


## Length:358 Length:358 Length:358
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## 12. Relation of respondent with household head
## Length:358
## Class :character
## Mode :character
##
##
##
## 22. Are you currently borrowing from another source
## Min. :0.000
## 1st Qu.:0.000
## Median :0.000
## Mean :0.405
## 3rd Qu.:1.000
## Max. :1.000
## 23.5 How does the amount your household spent on school and school
expenses for this current school year compare to what you spent last school
year
## Min. :-1.0000

## 1st Qu.:-1.0000

## Median : 0.0000

## Mean :-0.2374

## 3rd Qu.: 0.0000

## Max. : 1.0000

## 24. Did you invest any of the last loan you took from the program into an
income-generating activity
## Min. :0.000

## 1st Qu.:0.000

## Median :1.500

## Mean :1.042

## 3rd Qu.:2.000

## Max. :2.000

## 25. Over the last 12 months, has the household income you have been able
to earn.
## Min. :-2.0000

## 1st Qu.:-1.0000
## Median :-1.0000

## Mean :-0.7067

## 3rd Qu.: 0.0000

## Max. : 2.0000

## 32.1. Do you feel that productivity has increased after taking loan from
Saggraha MFI
## Min. :-1.0000

## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.9022

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.2. Do you feel that quality of life has improved after taking loan
from Saggraha MFI:
## Min. :-2.0000

## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.8994

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.3. Do you feel yourself more financially secure after taking loan from
Saggraha MFI:
## Min. :-2.000

## 1st Qu.: 1.000

## Median : 1.000

## Mean : 0.824

## 3rd Qu.: 1.000


## Max. : 2.000

## 32.4. Do you feel yourself and household members more healthy due to
better food and hygienic living conditions due to increase in income after
taking loan from Saggraha MFI
## Min. :-2.0000

## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.8492

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.5. Do you feel you have better coping capacity during emergency after
taking loan from Saggraha MFI:
## Min. :-1.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6927

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.6. Do you feel your overall peace of mind has improved due to loan
provided by Saggraha MFI:
## Min. :-2.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6732

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.1. Lower interest rate than other informal sources of credit (informal
lenders)
## Min. :-2.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6257

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.2. Steady source of working capital


## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5531
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.3. Group solidarity and/or group dynamics
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6453
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.4. Training or technical assistance
## Min. :-1.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6397
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.5. Other financial services, such as savings or insurance
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.7179
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.6. Efficiency, compared to banks or other sources
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6453
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.7. Easier guarantees than loan alternatives
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5196
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.8. High interest rates or charges
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 1.0000
## Mean : 0.3464
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.9. Size of initial or subsequent loans too small 34.10. Loan cycle too
long
## Min. :-2.0000 Min. :-2.00000

## 1st Qu.: 0.0000 1st Qu.:-1.00000

## Median : 1.0000 Median : 0.00000

## Mean : 0.3799 Mean : 0.05307

## 3rd Qu.: 1.0000 3rd Qu.: 1.00000

## Max. : 2.0000 Max. : 2.00000

## 34.11. Loan cycle too short


## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1536
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.12. Problematic group dynamics (with leaders or at meetings)
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.3966
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.13. Meeting frequency too often or meetings too long
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1872
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.14. Meeting place/ office not convenient
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1006
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.15. Repayment policies suitability (frequency, amount)
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5726
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.16. Insurance policies suitability (Claim settlement)
## Min. :-1.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6927
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.17. Low Transaction costs for client (such as slow disbursement, more
time consuming)
## Min. :-2.0000

## 1st Qu.:-1.0000

## Median : 1.0000

## Mean : 0.3631

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.18.Dislike behavior/ attitude of loan officer or other program


personnel
## Min. :-2.00000

## 1st Qu.:-1.00000

## Median : 0.00000

## Mean : 0.00838

## 3rd Qu.: 1.00000

## Max. : 2.00000

data2 <- select(data1, c(9:36))


summary(data2)
## 22. Are you currently borrowing from another source
## Min. :0.000
## 1st Qu.:0.000
## Median :0.000
## Mean :0.405
## 3rd Qu.:1.000
## Max. :1.000
## 23.5 How does the amount your household spent on school and school
expenses for this current school year compare to what you spent last school
year
## Min. :-1.0000

## 1st Qu.:-1.0000

## Median : 0.0000

## Mean :-0.2374

## 3rd Qu.: 0.0000

## Max. : 1.0000

## 24. Did you invest any of the last loan you took from the program into an
income-generating activity
## Min. :0.000

## 1st Qu.:0.000

## Median :1.500

## Mean :1.042

## 3rd Qu.:2.000

## Max. :2.000

## 25. Over the last 12 months, has the household income you have been able
to earn.
## Min. :-2.0000

## 1st Qu.:-1.0000

## Median :-1.0000

## Mean :-0.7067

## 3rd Qu.: 0.0000


## Max. : 2.0000

## 32.1. Do you feel that productivity has increased after taking loan from
Saggraha MFI
## Min. :-1.0000

## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.9022

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.2. Do you feel that quality of life has improved after taking loan
from Saggraha MFI:
## Min. :-2.0000

## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.8994

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.3. Do you feel yourself more financially secure after taking loan from
Saggraha MFI:
## Min. :-2.000

## 1st Qu.: 1.000

## Median : 1.000

## Mean : 0.824

## 3rd Qu.: 1.000

## Max. : 2.000

## 32.4. Do you feel yourself and household members more healthy due to
better food and hygienic living conditions due to increase in income after
taking loan from Saggraha MFI
## Min. :-2.0000
## 1st Qu.: 1.0000

## Median : 1.0000

## Mean : 0.8492

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.5. Do you feel you have better coping capacity during emergency after
taking loan from Saggraha MFI:
## Min. :-1.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6927

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 32.6. Do you feel your overall peace of mind has improved due to loan
provided by Saggraha MFI:
## Min. :-2.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6732

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.1. Lower interest rate than other informal sources of credit (informal
lenders)
## Min. :-2.0000

## 1st Qu.: 0.0000

## Median : 1.0000

## Mean : 0.6257
## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.2. Steady source of working capital


## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5531
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.3. Group solidarity and/or group dynamics
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6453
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.4. Training or technical assistance
## Min. :-1.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6397
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.5. Other financial services, such as savings or insurance
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.7179
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.6. Efficiency, compared to banks or other sources
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6453
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.7. Easier guarantees than loan alternatives
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5196
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.8. High interest rates or charges
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 1.0000
## Mean : 0.3464
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.9. Size of initial or subsequent loans too small 34.10. Loan cycle too
long
## Min. :-2.0000 Min. :-2.00000

## 1st Qu.: 0.0000 1st Qu.:-1.00000

## Median : 1.0000 Median : 0.00000

## Mean : 0.3799 Mean : 0.05307

## 3rd Qu.: 1.0000 3rd Qu.: 1.00000

## Max. : 2.0000 Max. : 2.00000

## 34.11. Loan cycle too short


## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1536
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.12. Problematic group dynamics (with leaders or at meetings)
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.3966
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.13. Meeting frequency too often or meetings too long
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1872
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.14. Meeting place/ office not convenient
## Min. :-2.0000
## 1st Qu.:-1.0000
## Median : 0.0000
## Mean : 0.1006
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.15. Repayment policies suitability (frequency, amount)
## Min. :-2.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.5726
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.16. Insurance policies suitability (Claim settlement)
## Min. :-1.0000
## 1st Qu.: 0.0000
## Median : 1.0000
## Mean : 0.6927
## 3rd Qu.: 1.0000
## Max. : 2.0000
## 34.17. Low Transaction costs for client (such as slow disbursement, more
time consuming)
## Min. :-2.0000

## 1st Qu.:-1.0000

## Median : 1.0000

## Mean : 0.3631

## 3rd Qu.: 1.0000

## Max. : 2.0000

## 34.18.Dislike behavior/ attitude of loan officer or other program


personnel
## Min. :-2.00000

## 1st Qu.:-1.00000

## Median : 0.00000

## Mean : 0.00838

## 3rd Qu.: 1.00000

## Max. : 2.00000

kmean_withinss <- function(k) {


cluster <- kmeans(data2, k)
return (cluster$tot.withinss)
}

#kmean_withinss(2)

max_k <-20
# Run algorithm over a range of k
wss <- sapply(2:max_k, kmean_withinss)

elbow <-data.frame(2:max_k, wss)


ggplot(elbow, aes(x = X2.max_k, y = wss)) +
geom_point() +
geom_line() +
scale_x_continuous(breaks = seq(1, 20, by = 1))

pc_cluster_2 <-kmeans(data2, 4)
pc_cluster_2$cluster

## [1] 3 3 1 2 4 4 3 4 3 2 4 3 2 2 4 4 4 4 3 4 3 3 3 4 3 4 3 2 2 2 2 2 2 2
2 2 2
## [38] 4 4 4 4 4 4 4 4 4 3 3 3 4 4 4 4 2 2 2 3 3 4 3 4 4 4 4 4 3 3 4 4 4 4
3 4 4
## [75] 4 2 3 3 4 1 4 4 3 3 4 2 3 4 4 4 3 3 3 3 4 1 1 1 2 3 1 3 3 4 2 2 1 1
4 4 4
## [112] 1 1 1 1 1 4 3 3 4 3 1 1 1 2 3 3 3 1 3 3 3 3 3 2 2 3 2 4 4 4 4 4 4 4
4 2 2
## [149] 2 2 2 2 2 2 2 2 3 4 3 3 3 4 4 4 4 4 2 2 2 2 2 2 2 3 4 3 2 2 2 4 4 3
3 3 4
## [186] 3 2 3 3 3 3 4 4 3 3 4 4 4 3 4 3 3 3 3 4 3 3 4 3 4 4 4 4 3 3 4 4 4 4
4 2 3
## [223] 1 3 1 3 1 3 3 4 3 3 3 2 2 2 2 2 2 3 3 3 4 3 3 4 4 4 4 4 4 3 4 3 4 2
2 2 2
## [260] 2 2 3 4 4 3 3 3 3 3 1 3 3 3 1 1 1 4 4 4 3 4 1 4 3 4 4 4 4 4 1 3 4 3
4 3 4
## [297] 3 3 3 3 3 3 4 3 4 4 2 2 2 2 2 2 3 4 3 1 1 1 4 4 4 1 4 4 4 4 4 4 4 4
3 3 3
## [334] 3 4 4 4 4 2 2 3 2 4 4 4 3 3 3 1 4 4 4 4 3 4 3 4 3

pc_cluster_2$size

## [1] 31 69 119 139

pc_cluster_2$centers

## 22. Are you currently borrowing from another source


## 1 0.2258065
## 2 0.3478261
## 3 0.4201681
## 4 0.4604317
## 23.5 How does the amount your household spent on school and school
expenses for this current school year compare to what you spent last school
year
## 1
0.06451613
## 2
-0.46376812
## 3
-0.12605042
## 4
-0.28776978
## 24. Did you invest any of the last loan you took from the program into
an income-generating activity
## 1
0.9032258
## 2
1.8550725
## 3
1.0756303
## 4
0.6402878
## 25. Over the last 12 months, has the household income you have been able
to earn.
## 1
-0.2903226
## 2
-0.9130435
## 3
-0.4789916
## 4
-0.8920863
## 32.1. Do you feel that productivity has increased after taking loan from
Saggraha MFI
## 1
-0.3870968
## 2
1.2028986
## 3
0.7226891
## 4
1.1942446
## 32.2. Do you feel that quality of life has improved after taking loan
from Saggraha MFI:
## 1
-0.3225806
## 2
1.1304348
## 3
0.7058824
## 4
1.2230216
## 32.3. Do you feel yourself more financially secure after taking loan
from Saggraha MFI:
## 1
-0.5806452
## 2
1.0579710
## 3
0.6050420
## 4
1.2086331
## 32.4. Do you feel yourself and household members more healthy due to
better food and hygienic living conditions due to increase in income after
taking loan from Saggraha MFI
## 1
-0.7096774
## 2
0.8405797
## 3
0.7478992
## 4
1.2877698
## 32.5. Do you feel you have better coping capacity during emergency after
taking loan from Saggraha MFI:
## 1
-0.7741935
## 2
1.1594203
## 3
0.4033613
## 4
1.0359712
## 32.6. Do you feel your overall peace of mind has improved due to loan
provided by Saggraha MFI:
## 1
-0.7419355
## 2
0.9420290
## 3
0.4957983
## 4
1.0071942
## 34.1. Lower interest rate than other informal sources of credit
(informal lenders)
## 1
-0.8064516
## 2
0.9710145
## 3
0.3361345
## 4
1.0215827
## 34.2. Steady source of working capital
## 1 -0.8387097
## 2 0.9130435
## 3 0.1008403
## 4 1.0719424
## 34.3. Group solidarity and/or group dynamics
## 1 -0.7741935
## 2 0.8550725
## 3 0.3529412
## 4 1.1079137
## 34.4. Training or technical assistance
## 1 -0.8064516
## 2 1.0434783
## 3 0.2773109
## 4 1.0719424
## 34.5. Other financial services, such as savings or insurance
## 1 -0.7741935
## 2 1.2173913
## 3 0.3865546
## 4 1.0863309
## 34.6. Efficiency, compared to banks or other sources
## 1 -0.8709677
## 2 1.2463768
## 3 0.3277311
## 4 0.9568345
## 34.7. Easier guarantees than loan alternatives
## 1 -0.87096774
## 2 1.00000000
## 3 0.09243697
## 4 0.95683453
## 34.8. High interest rates or charges
## 1 -0.6451613
## 2 -0.4492754
## 3 0.2521008
## 4 1.0431655
## 34.9. Size of initial or subsequent loans too small
## 1 -0.8387097
## 2 -0.2028986
## 3 0.2352941
## 4 1.0647482
## 34.10. Loan cycle too long 34.11. Loan cycle too short
## 1 -0.9354839 -0.8387097
## 2 -0.8260870 -0.4637681
## 3 0.0000000 0.1008403
## 4 0.7553957 0.7266187
## 34.12. Problematic group dynamics (with leaders or at meetings)
## 1 -0.5483871
## 2 -0.3768116
## 3 0.4117647
## 4 0.9784173
## 34.13. Meeting frequency too often or meetings too long
## 1 -0.6774194
## 2 -0.6376812
## 3 0.1260504
## 4 0.8417266
## 34.14. Meeting place/ office not convenient
## 1 -0.74193548
## 2 -0.49275362
## 3 0.08403361
## 4 0.59712230
## 34.15. Repayment policies suitability (frequency, amount)
## 1 -0.7419355
## 2 0.9565217
## 3 0.2016807
## 4 0.9928058
## 34.16. Insurance policies suitability (Claim settlement)
## 1 -0.7096774
## 2 1.1594203
## 3 0.3865546
## 4 1.0359712
## 34.17. Low Transaction costs for client (such as slow disbursement, more
time consuming)
## 1
-0.4838710
## 2
-0.4492754
## 3
0.1848739
## 4
1.1079137
## 34.18.Dislike behavior/ attitude of loan officer or other program
personnel
## 1
-0.67741935
## 2
-0.86956522
## 3
0.04201681
## 4
0.56834532

autoplot(pc_cluster_2, data2, frame = TRUE)

## Adding missing grouping variables: `cluster`

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy