#Información general
summary(base[ , c(2:16)])
TPVLDA Computadora Internet Celular tot sucursales
Min. :-1.4670 Min. :-2.56248 Min. :-1.3280 Min. :-1.5799 Min. :-2.3223
1st Qu.:-0.5313 1st Qu.:-0.65348 1st Qu.:-0.7261 1st Qu.:-0.6467 1st Qu.:-0.7828
Median :-0.2923 Median : 0.09301 Median :-0.1743 Median :-0.1742 Median : 0.2951
Mean : 0.0000 Mean : 0.00000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
3rd Qu.: 0.3628 3rd Qu.: 0.65572 3rd Qu.: 0.5216 3rd Qu.: 0.6829 3rd Qu.: 0.7893
Max. : 2.5531 Max. : 1.88630 Max. : 2.8138 Max. : 2.8156 Max. : 1.5071
credito personal ANALF SBASC OVSDE OVSEE
Min. :-1.7849 Min. :-1.0318 Min. :-1.5978 Min. :-0.8760 Min. :-1.1990
1st Qu.:-0.6422 1st Qu.:-0.6574 1st Qu.:-0.6752 1st Qu.:-0.6183 1st Qu.:-0.6763
Median : 0.1947 Median :-0.3738 Median :-0.1598 Median :-0.1978 Median :-0.3841
Mean : 0.0000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
3rd Qu.: 0.6402 3rd Qu.: 0.3763 3rd Qu.: 0.2966 3rd Qu.: 0.1351 3rd Qu.: 0.4755
Max. : 1.9786 Max. : 2.8364 Max. : 2.4983 Max. : 4.1446 Max. : 2.2777
OVSAE OVPT VHAC PL.5000 PO2SM
Min. :-0.9378 Min. :-0.8617 Min. :-1.1058 Min. :-1.66967 Min. :-2.26077
1st Qu.:-0.7031 1st Qu.:-0.5517 1st Qu.:-0.7584 1st Qu.:-0.86083 1st Qu.:-0.75536
Median :-0.4028 Median :-0.3700 Median :-0.2699 Median : 0.05406 Median : 0.09959
Mean : 0.0000 Mean : 0.0000 Mean : 0.0000 Mean : 0.00000 Mean : 0.00000
3rd Qu.: 0.2750 3rd Qu.: 0.1823 3rd Qu.: 0.6159 3rd Qu.: 0.52689 3rd Qu.: 0.67245
Max. : 2.5912 Max. : 3.1578 Max. : 2.6345 Max. : 1.92051 Max. : 1.90994
boxplot(base$TPVLDA)
boxplot(base$Computadora)
boxplot(base$Internet)
boxplot(base$Celular)
boxplot(base$`tot sucursales`)
boxplot(base$`credito personal`)
boxplot(base$ANALF)
boxplot(base$SBASC)
boxplot(base$OVSDE)
boxplot(base$OVSEE)
boxplot(base$OVSAE)
boxplot(base$OVPT)
boxplot(base$VHAC)
boxplot(base$PL.5000)
boxplot(base$PO2SM)
#Outliers multivariados (paqueter?a mvoutlier)
sign2(base[ , c(2:16)], makeplot = T)
$wfinal01
[1] 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 1
$x.dist
[1] 3.029409 3.716198 5.775303 3.434803 2.147148 3.822039 6.365092 3.942662 3.938364
[10] 4.656607 2.663701 14.154400 3.134436 2.737565 2.727689 3.966358 3.279303 5.183301
[19] 3.242875 6.913043 2.606947 2.744266 3.814099 3.607587 2.387355 2.037107 3.300276
[28] 2.154322 2.794889 4.114330 5.846786 3.034652
$const
[1] 4.830804
cor(base[ , c(2:16)])
TPVLDA Computadora Internet Celular tot sucursales credito personal
TPVLDA 1.00000000 0.3211264 0.2520438 0.2084463 0.1141993 0.09570040
Computadora 0.32112643 1.0000000 0.9207734 0.8717914 0.4501411 -0.25916431
Internet 0.25204377 0.9207734 1.0000000 0.9635150 0.4241603 -0.23703187
Celular 0.20844633 0.8717914 0.9635150 1.0000000 0.4470104 -0.27069204
tot sucursales 0.11419929 0.4501411 0.4241603 0.4470104 1.0000000 -0.19762609
credito personal 0.09570040 -0.2591643 -0.2370319 -0.2706920 -0.1976261 1.00000000
ANALF 0.33184509 0.8355190 0.8977926 0.8917320 0.3837681 -0.33572067
SBASC 0.33991048 0.8903111 0.9129792 0.8701910 0.3900256 -0.19620873
OVSDE 0.44664125 0.5422728 0.4308686 0.4511071 0.1983923 -0.34739819
OVSEE 0.73090281 0.4304681 0.4650434 0.4814938 0.2844547 -0.00947867
OVSAE 0.42046604 0.6894991 0.7669452 0.7690263 0.4094815 -0.31258891
OVPT 0.53331816 0.6912093 0.7385973 0.7217778 0.3297049 -0.27943586
VHAC 0.25982876 0.6153161 0.6576599 0.7020129 0.4172392 -0.39888500
PL.5000 0.27971594 0.8824886 0.8882354 0.8566881 0.5306178 -0.27544375
PO2SM 0.04989999 0.6794932 0.6729675 0.6917547 0.7300096 -0.39897534
ANALF SBASC OVSDE OVSEE OVSAE OVPT VHAC
TPVLDA 0.3318451 0.3399105 0.4466413 0.73090281 0.4204660 0.5333182 0.2598288
Computadora 0.8355190 0.8903111 0.5422728 0.43046811 0.6894991 0.6912093 0.6153161
Internet 0.8977926 0.9129792 0.4308686 0.46504339 0.7669452 0.7385973 0.6576599
Celular 0.8917320 0.8701910 0.4511071 0.48149379 0.7690263 0.7217778 0.7020129
tot sucursales 0.3837681 0.3900256 0.1983923 0.28445466 0.4094815 0.3297049 0.4172392
credito personal -0.3357207 -0.1962087 -0.3473982 -0.00947867 -0.3125889 -0.2794359 -0.3988850
ANALF 1.0000000 0.9285371 0.5886507 0.51688213 0.8607664 0.8901424 0.8217527
SBASC 0.9285371 1.0000000 0.4882323 0.49419507 0.7459456 0.8086467 0.6862301
OVSDE 0.5886507 0.4882323 1.0000000 0.48192354 0.4670627 0.5478587 0.5609712
OVSEE 0.5168821 0.4941951 0.4819235 1.00000000 0.5623158 0.6313315 0.4303666
OVSAE 0.8607664 0.7459456 0.4670627 0.56231577 1.0000000 0.9012056 0.7207574
OVPT 0.8901424 0.8086467 0.5478587 0.63133146 0.9012056 1.0000000 0.7200972
VHAC 0.8217527 0.6862301 0.5609712 0.43036664 0.7207574 0.7200972 1.0000000
PL.5000 0.8109444 0.8019325 0.4768334 0.47696644 0.7136100 0.6556000 0.6140227
PO2SM 0.6951518 0.7177941 0.3944560 0.36833528 0.5491192 0.5387849 0.6135388
PL.5000 PO2SM
TPVLDA 0.2797159 0.04989999
Computadora 0.8824886 0.67949316
Internet 0.8882354 0.67296749
Celular 0.8566881 0.69175471
tot sucursales 0.5306178 0.73000957
credito personal -0.2754437 -0.39897534
ANALF 0.8109444 0.69515179
SBASC 0.8019325 0.71779412
OVSDE 0.4768334 0.39445603
OVSEE 0.4769664 0.36833528
OVSAE 0.7136100 0.54911917
OVPT 0.6556000 0.53878493
VHAC 0.6140227 0.61353883
PL.5000 1.0000000 0.69564447
PO2SM 0.6956445 1.00000000
abs(cor(base[ , c(2:16)])) > 0.6
TPVLDA Computadora Internet Celular tot sucursales credito personal ANALF SBASC
TPVLDA TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
Computadora FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
Internet FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
Celular FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
tot sucursales FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
credito personal FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
ANALF FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
SBASC FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
OVSDE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
OVSEE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
OVSAE FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
OVPT FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
VHAC FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
PL.5000 FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE
PO2SM FALSE TRUE TRUE TRUE TRUE FALSE TRUE TRUE
OVSDE OVSEE OVSAE OVPT VHAC PL.5000 PO2SM
TPVLDA FALSE TRUE FALSE FALSE FALSE FALSE FALSE
Computadora FALSE FALSE TRUE TRUE TRUE TRUE TRUE
Internet FALSE FALSE TRUE TRUE TRUE TRUE TRUE
Celular FALSE FALSE TRUE TRUE TRUE TRUE TRUE
tot sucursales FALSE FALSE FALSE FALSE FALSE FALSE TRUE
credito personal FALSE FALSE FALSE FALSE FALSE FALSE FALSE
ANALF FALSE FALSE TRUE TRUE TRUE TRUE TRUE
SBASC FALSE FALSE TRUE TRUE TRUE TRUE TRUE
OVSDE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
OVSEE FALSE TRUE FALSE TRUE FALSE FALSE FALSE
OVSAE FALSE FALSE TRUE TRUE TRUE TRUE FALSE
OVPT FALSE TRUE TRUE TRUE TRUE TRUE FALSE
VHAC FALSE FALSE TRUE TRUE TRUE TRUE TRUE
PL.5000 FALSE FALSE TRUE TRUE TRUE TRUE TRUE
PO2SM FALSE FALSE FALSE FALSE TRUE TRUE TRUE
KMO(base[ , c(2:16)])
Kaiser-Meyer-Olkin factor adequacy
Call: KMO(r = base[, c(2:16)])
Overall MSA = 0.86
MSA for each item =
TPVLDA Computadora Internet Celular tot sucursales
0.69 0.87 0.88 0.90 0.72
credito personal ANALF SBASC OVSDE OVSEE
0.71 0.85 0.86 0.81 0.77
OVSAE OVPT VHAC PL.5000 PO2SM
0.93 0.89 0.92 0.92 0.80
base.pca <- prcomp(base[ , c(2:16)], center = TRUE, scale = TRUE)
summary(base.pca)
Importance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 3.0284 1.2934 1.0370 0.96640 0.76478 0.65986 0.55518 0.51059 0.46916
Proportion of Variance 0.6114 0.1115 0.0717 0.06226 0.03899 0.02903 0.02055 0.01738 0.01467
Cumulative Proportion 0.6114 0.7229 0.7946 0.85691 0.89590 0.92493 0.94548 0.96286 0.97753
PC10 PC11 PC12 PC13 PC14 PC15
Standard deviation 0.34873 0.26923 0.25879 0.20083 0.13831 0.1282
Proportion of Variance 0.00811 0.00483 0.00446 0.00269 0.00128 0.0011
Cumulative Proportion 0.98564 0.99047 0.99494 0.99763 0.99890 1.0000
base.pca$rotation
PC1 PC2 PC3 PC4 PC5 PC6
TPVLDA 0.1386124 0.63072748 0.03104095 -0.209389803 0.05293211 -0.22969467
Computadora 0.2968004 -0.07794920 -0.16116583 0.117830164 0.34697131 -0.15121997
Internet 0.3043960 -0.09893402 -0.22596556 0.203106779 0.07950990 -0.15158576
Celular 0.3025390 -0.12026165 -0.16946635 0.163628090 0.03319264 -0.06372044
tot sucursales 0.1762639 -0.24855421 -0.14122994 -0.751065728 -0.08909099 0.06905875
credito personal -0.1163164 0.31563549 -0.72603509 0.008573354 0.05003200 0.55145884
ANALF 0.3169304 -0.01574866 0.02960649 0.196651968 -0.10600890 0.15385818
SBASC 0.3043545 -0.02292677 -0.17337134 0.173955377 0.05195059 0.06999864
OVSDE 0.2056990 0.19911110 0.45483532 -0.025715255 0.61830973 0.37575642
OVSEE 0.2046488 0.46426561 -0.02223843 -0.295343191 -0.03921245 -0.17921010
OVSAE 0.2874131 0.08827898 0.05748820 0.082576811 -0.45524956 -0.07781626
OVPT 0.2890336 0.19340899 0.09845259 0.108467722 -0.36228409 0.02347033
VHAC 0.2660755 -0.04856623 0.25535519 0.023037695 -0.25893388 0.55202794
PL.5000 0.2921200 -0.10684418 -0.17145410 -0.005960827 0.23043395 -0.25393540
PO2SM 0.2537009 -0.30905499 -0.01747706 -0.366197254 0.05015325 0.10369582
PC7 PC8 PC9 PC10 PC11 PC12
TPVLDA 0.31073631 -0.14987859 -0.45382577 0.02573263 -0.25458838 0.29239459
Computadora 0.21174043 -0.08353801 -0.16788764 0.09782674 -0.08048039 -0.71956673
Internet -0.03141060 0.12088119 -0.03925252 0.26431614 0.01273083 0.11589127
Celular -0.16788254 0.29459226 0.03374277 0.48405247 -0.15875093 0.34275185
tot sucursales 0.35289697 0.08935195 0.06108683 0.27096440 0.27706875 0.01939850
credito personal 0.05572142 0.02586564 0.15569151 -0.09378484 -0.08455648 -0.01394581
ANALF -0.03287977 -0.11856126 0.02219990 -0.06061847 0.16441373 0.29838739
SBASC -0.09036980 -0.46240223 -0.17765432 0.02469125 0.18013136 0.02581226
OVSDE 0.10968392 0.02806896 0.38027429 0.08998794 -0.01682058 0.07387313
OVSEE -0.66113250 0.22291851 0.12338426 0.02193683 0.16353229 -0.26179158
OVSAE 0.27047543 0.12213930 0.44087221 -0.06730859 -0.53032322 -0.16528312
OVPT 0.13008472 -0.32360802 0.23551963 -0.03634321 0.45705305 -0.06927778
VHAC -0.04651288 0.37014462 -0.54026252 -0.10642517 -0.02433131 -0.16480254
PL.5000 0.13366869 0.36179087 0.03778812 -0.71676926 0.17521064 0.18683765
PO2SM -0.36511962 -0.44115212 0.01302651 -0.24409337 -0.45988143 0.08584422
PC13 PC14 PC15
TPVLDA -0.07785972 0.011250096 0.02147511
Computadora -0.16738369 -0.107249282 0.26339420
Internet 0.01842487 0.797950259 -0.19565951
Celular -0.29052628 -0.501672629 -0.06462256
tot sucursales 0.14678386 -0.011179644 0.04373389
credito personal -0.09126932 0.020691462 0.01106197
ANALF 0.15743691 0.062826226 0.81286077
SBASC 0.59000917 -0.264492445 -0.36550245
OVSDE 0.04702854 0.042173809 -0.10840270
OVSEE 0.13567779 0.006816167 0.07052636
OVSAE 0.29541531 -0.024026659 -0.05278970
OVPT -0.54052690 -0.002375206 -0.20368450
VHAC -0.03862651 0.034044865 -0.12862041
PL.5000 -0.03134537 -0.110797154 -0.11585997
PO2SM -0.27544248 0.098343278 -0.01918130
parallel <- fa.parallel(base[ , c(2:16)],fm="minres",fa='fa') #Sugiere un solo factor
Warning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: An ultra-Heywood case was detected. Examine the results carefullyWarning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: The estimated weights for the factor scores are probably incorrect. Try a different factor score estimation method.Warning: An ultra-Heywood case was detected. Examine the results carefully
Parallel analysis suggests that the number of factors = 1 and the number of components = NA
dimensiones <- c("TPVLDA","Computadora", "Internet","Celular","tot sucursales","credito personal","ANALF", "SBASC", "OVSDE", "OVSAE", "OVPT", "OVSEE", "VHAC", "PL.5000", "PO2SM")
# implementacion de fase previa de FA
summary(pre_factor(base, vars = dimensiones))
Pre-factor analysis diagnostics
Data : base
Variables : TPVLDA, Computadora, Internet, Celular, tot sucursales, credito personal, ANALF, SBASC, OVSDE, OVSAE, OVPT, OVSEE, VHAC, PL.5000, PO2SM
Observations: 32
Correlation : Pearson
Bartlett test
Null hyp. : variables are not correlated
Alt. hyp. : variables are correlated
Chi-square: 537.99 df(105), p.value < .001
KMO test: 0.86
Variable collinearity:
Fit measures:
# implementacion del FA
summary(full_factor(base, dimensiones, nr_fact = length(dimensions)))
Factor analysis
Data : base
Variables : TPVLDA, Computadora, Internet, Celular, tot sucursales, credito personal, ANALF, SBASC, OVSDE, OVSAE, OVPT, OVSEE, VHAC, PL.5000, PO2SM
Factors : 9
Method : PCA
Rotation : varimax
Observations: 32
Correlation : Pearson
Factor loadings:
Fit measures:
Attribute communalities:
Factor scores (max 10 shown):
#Varimax
fa.varimax <- fa(base[ , c(2:16)], rotate="varimax", nfactors= 1)
print(fa.varimax$loadings[1:9,])
TPVLDA Computadora Internet Celular tot sucursales
0.3854954 0.8942971 0.9235486 0.9161628 0.4973958
credito personal ANALF SBASC OVSDE
-0.3229777 0.9695611 0.9227021 0.5861276
#Oblimin
fa.oblimin <- fa(base[ , c(2:16)], rotate="oblimin", nfactors= 1)
print(fa.oblimin$loadings[1:9,])
TPVLDA Computadora Internet Celular tot sucursales
0.3854954 0.8942971 0.9235486 0.9161628 0.4973958
credito personal ANALF SBASC OVSDE
-0.3229777 0.9695611 0.9227021 0.5861276
Ambos resultados son iguales pues solo es un factor
base$TPVLDA_f= base$TPVLDA * base.pca$rotation[1]
base$Computadora_f= base$Computadora * base.pca$rotation[2]
base$Internet_f = base$Internet * base.pca$rotation[3]
base$Celular_f = base$Celular * base.pca$rotation[4]
base$sucursales_f = base$`tot sucursales` * base.pca$rotation[5]
base$credito_personal_f = base$`credito personal` * base.pca$rotation[6]
base$ANALF_f = base$ANALF * base.pca$rotation[7]
base$SBASC_f = base$SBASC * base.pca$rotation[8]
base$OVSDE_f = base$OVSDE * base.pca$rotation[9]
base$OVSEE_f = base$OVSEE * base.pca$rotation[10]
base$OVSAE_f = base$OVSAE * base.pca$rotation[11]
base$OVPT_f = base$OVPT * base.pca$rotation[12]
base$VHAC_f = base$VHAC * base.pca$rotation[13]
base$PL.5000_f = base$PL.5000 * base.pca$rotation[14]
base$PO2SM_f = base$PO2SM * base.pca$rotation[15]
FS = rowSums(base[17:31])
base$indice_marginacion = FS
m.distancia <- get_dist(df, method = "euclidean")
fviz_dist(m.distancia, gradient = list(low = "blue", mid = "white", high = "red"))
resnumclust<- NbClust(df[2:length(df)], distance = "euclidean", min.nc=2, max.nc=10, method = "kmeans", index = "alllong")
Warning: NaNs produced
*** : The Hubert index is a graphical method of determining the number of clusters.
In the plot of Hubert index, we seek a significant knee that corresponds to a
significant increase of the value of the measure i.e the significant peak in Hubert
index second differences plot.
*** : The D index is a graphical method of determining the number of clusters.
In the plot of D index, we seek a significant knee (the significant peak in Dindex
second differences plot) that corresponds to a significant increase of the value of
the measure.
*******************************************************************
* Among all indices:
* 4 proposed 2 as the best number of clusters
* 15 proposed 3 as the best number of clusters
* 2 proposed 5 as the best number of clusters
* 3 proposed 7 as the best number of clusters
* 3 proposed 10 as the best number of clusters
***** Conclusion *****
* According to the majority rule, the best number of clusters is 3
*******************************************************************
k3 <- kmeans(df[2:length(df)], centers = 3, nstart = 25)
k3
K-means clustering with 3 clusters of sizes 14, 3, 15
Cluster means:
Internet Celular tot sucursales credito personal ANALF SBASC OVSDE
1 0.4157513 0.4342305 0.2419071 -0.2945925 0.2100660 0.3101229 0.2495675
2 1.9665695 2.0083337 0.9647562 -0.7043717 2.5100662 2.1219295 1.5674243
3 -0.7813485 -0.8069485 -0.4187312 0.4158273 -0.6980748 -0.7138339 -0.5464146
OVSEE OVSAE OVPT VHAC PL.5000 PO2SM
1 0.1476553 0.1243782 -0.05473154 0.1740851 0.5553052 0.4517736
2 1.5822649 2.3317319 2.77763282 2.0982836 1.6536253 1.4933155
3 -0.4542646 -0.5824327 -0.50444379 -0.5821361 -0.8490099 -0.7203184
Clustering vector:
[1] 3 3 3 1 3 3 2 3 3 1 1 2 1 3 3 1 1 1 3 2 1 3 3 1 3 3 1 3 1 1 1 1
Within cluster sum of squares by cluster:
[1] 74.41930 17.72338 70.67351
(between_SS / total_SS = 59.6 %)
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss"
[7] "size" "iter" "ifault"
str(k3)
List of 9
$ cluster : int [1:32] 3 3 3 1 3 3 2 3 3 1 ...
$ centers : num [1:3, 1:13] 0.416 1.967 -0.781 0.434 2.008 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:3] "1" "2" "3"
.. ..$ : chr [1:13] "Internet" "Celular" "tot sucursales" "credito personal" ...
$ totss : num 403
$ withinss : num [1:3] 74.4 17.7 70.7
$ tot.withinss: num 163
$ betweenss : num 240
$ size : int [1:3] 14 3 15
$ iter : int 2
$ ifault : int 0
- attr(*, "class")= chr "kmeans"
df$cluster <- k3$cluster_3
fviz_cluster(k3, data = df[2:length(df)])
fviz_cluster(k3, data = df[2:length(df)], ellipse.type = "euclid",repel = TRUE,star.plot = TRUE) #ellipse.type= "t", "norm", "euclid"
fviz_cluster(k3, data = df[2:length(df)], ellipse.type = "norm")
fviz_cluster(k3, data = df[2:length(df)], ellipse.type = "norm",palette = "Set2", ggtheme = theme_minimal())
res3 <- hcut(df[2:length(df)], k = 3, stand = TRUE)
fviz_dend(res3, rect = TRUE, cex = 0.5,
k_colors = c("green","red", "blue"))
Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as of ggplot2 3.3.4.
k5 <- kmeans(df[2:length(df)], centers = 5, nstart = 25)
k5
K-means clustering with 5 clusters of sizes 8, 11, 3, 7, 3
Cluster means:
Internet Celular tot sucursales credito personal ANALF SBASC OVSDE
1 -0.7641724 -0.81970809 0.5152920 0.2869474 -0.72289859 -0.62433809 -0.51698898
2 0.5651552 0.57713179 0.3802326 -0.3188716 0.29314632 0.40084363 -0.05620644
3 -0.1320630 -0.08974102 -0.2652862 -0.2055692 -0.09456189 -0.02251995 1.37073878
4 -0.8009782 -0.79236617 -1.4861863 0.5631187 -0.66970481 -0.81611485 -0.58004381
5 1.9665695 2.00833374 0.9647562 -0.7043717 2.51006616 2.12192953 1.56742434
OVSEE OVSAE OVPT VHAC PL.5000 PO2SM
1 -0.3640065 -0.6194047 -0.56168166 -0.63022649 -0.7405673 -0.15190668
2 -0.2090412 0.2759344 -0.02825534 0.21219139 0.6632019 0.55497854
3 1.4555424 -0.4313281 -0.15181095 0.03436199 0.1596838 0.07335534
4 -0.5574167 -0.5401789 -0.43902908 -0.52717573 -0.9729444 -1.36993186
5 1.5822649 2.3317319 2.77763282 2.09828359 1.6536253 1.49331549
Clustering vector:
[1] 1 1 4 2 1 4 5 1 4 3 2 5 2 4 1 2 2 3 4 5 2 4 4 2 1 1 2 1 2 2 3 2
Within cluster sum of squares by cluster:
[1] 22.60951 45.05272 11.61840 26.65406 17.72338
(between_SS / total_SS = 69.3 %)
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss"
[7] "size" "iter" "ifault"
str(k5)
List of 9
$ cluster : int [1:32] 1 1 4 2 1 4 5 1 4 3 ...
$ centers : num [1:5, 1:13] -0.764 0.565 -0.132 -0.801 1.967 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:5] "1" "2" "3" "4" ...
.. ..$ : chr [1:13] "Internet" "Celular" "tot sucursales" "credito personal" ...
$ totss : num 403
$ withinss : num [1:5] 22.6 45.1 11.6 26.7 17.7
$ tot.withinss: num 124
$ betweenss : num 279
$ size : int [1:5] 8 11 3 7 3
$ iter : int 3
$ ifault : int 0
- attr(*, "class")= chr "kmeans"
df$cluster <- k3$cluster_5
fviz_cluster(k5, data = df[2:length(df)])
fviz_cluster(k5, data = df[2:length(df)], ellipse.type = "euclid",repel = TRUE,star.plot = TRUE) #ellipse.type= "t", "norm", "euclid"
fviz_cluster(k5, data = df[2:length(df)], ellipse.type = "norm")
fviz_cluster(k5, data = df[2:length(df)], ellipse.type = "norm",palette = "Set2", ggtheme = theme_minimal())
res5 <- hcut(df[2:length(df)], k = 5, stand = TRUE)
fviz_dend(res5, rect = TRUE, cex = 0.5,
k_colors = c("green","red", "blue"))
Warning: Length of color vector was shorter than the number of clusters - color vector was recycled