Installing packages and loading datset

#install.packages("corrplot")
library(corrplot)
#install.packages("factoextra")
library(factoextra)
library(readxl)
glob_financial_dev <- read_excel("C:/Users/stran/Desktop/UW/UL/glob_financial_dev.xlsx", col_types = c("text", "text", "numeric", 
"text", "text", "text", "numeric", 
 "numeric", "numeric", "numeric", 
"numeric", "numeric", "numeric", 
"numeric", "numeric", "numeric", 
"numeric", "numeric"))

Checkiing correlation

cor_matrix <- cor(glob_financial_dev[,8:18], use = "complete.obs", method = "pearson")
corrplot(cor_matrix, method = "color", type = "upper", tl.cex = 0.8, tl.col = "black")

Filling NA’s

glob_financial_dev$ai10[is.na(glob_financial_dev$ai10)] <- mean((glob_financial_dev$ai10), na.rm = TRUE)
glob_financial_dev$ai23[is.na(glob_financial_dev$ai23)] <- mean((glob_financial_dev$ai23), na.rm = TRUE)

Normalizing data

scaled_data <- scale(glob_financial_dev[,8:18])

PCA & doing loadings

pca_result2 <- prcomp(scaled_data, center = FALSE, scale. = FALSE)
summary(pca_result2)
## Importance of components:
##                           PC1    PC2     PC3     PC4     PC5     PC6     PC7
## Standard deviation     2.6729 1.1866 1.02295 0.78589 0.55262 0.51620 0.30436
## Proportion of Variance 0.6495 0.1280 0.09513 0.05615 0.02776 0.02422 0.00842
## Cumulative Proportion  0.6495 0.7775 0.87263 0.92878 0.95654 0.98076 0.98919
##                            PC8     PC9    PC10    PC11
## Standard deviation     0.20849 0.18741 0.16438 0.11555
## Proportion of Variance 0.00395 0.00319 0.00246 0.00121
## Cumulative Proportion  0.99314 0.99633 0.99879 1.00000
pca_result1 <- princomp(scaled_data)
loadings(pca_result1)
## 
## Loadings:
##      Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9 Comp.10
## ai05  0.339  0.104  0.179  0.182  0.485  0.252  0.211  0.562         0.313 
## ai06  0.352               -0.267        -0.268  0.613 -0.378  0.445  0.106 
## ai07  0.347        -0.284        -0.200  0.313  0.182  0.291        -0.319 
## ai10 -0.131 -0.576  0.539 -0.252 -0.117  0.465  0.207        -0.126        
## ai12  0.302 -0.227  0.108 -0.530        -0.541 -0.219  0.338 -0.316        
## ai14  0.195 -0.523 -0.566                                           -0.246 
## ai18 -0.258 -0.495 -0.198  0.269  0.511 -0.184        -0.116         0.252 
## ai20  0.351        -0.241        -0.197  0.278        -0.357 -0.474  0.586 
## ai21  0.345  0.123  0.182  0.159  0.435               -0.395 -0.399 -0.550 
## ai22  0.346 -0.139  0.231                0.136 -0.656 -0.185  0.531  0.115 
## ai23  0.257 -0.223  0.286  0.669 -0.459 -0.347  0.112                      
##      Comp.11
## ai05  0.227 
## ai06        
## ai07 -0.661 
## ai10        
## ai12        
## ai14  0.531 
## ai18 -0.443 
## ai20        
## ai21        
## ai22 -0.147 
## ai23        
## 
##                Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9
## SS loadings     1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000
## Proportion Var  0.091  0.091  0.091  0.091  0.091  0.091  0.091  0.091  0.091
## Cumulative Var  0.091  0.182  0.273  0.364  0.455  0.545  0.636  0.727  0.818
##                Comp.10 Comp.11
## SS loadings      1.000   1.000
## Proportion Var   0.091   0.091
## Cumulative Var   0.909   1.000

Plots

plot(pca_result1)

fviz_pca_var(pca_result1, col.var="steelblue")

fviz_eig(pca_result1, choice='eigenvalue')

ai18 and ai10 are negetivly correlated with almost everything else.

ai18- The percentage of respondents who report borrowing any money from family, relatives, or friends in the past year

ai10- The percentage of respondents who report personally receiving any money in the past year from a relative or friend living in a different area of their country, and received it into a financial institution account or a mobile money account

ai07 - The percentage of respondents who report borrowing any money from a bank or another type of financial institution or using a credit card in the past year

Conclusions that i can extract:

  1. If person borrows money from bank, they don’t tend to borrow it from relatives/friends since ai18 and ai07 are negatively correlated.

  2. Person tends to borrow money from institutions or using credit card, when they have credit or debit card (ai20 and ai21)

  3. 3 first PC-s can big fraction of variance and over 85% of Cumulative Proportion