You are on page 1of 19

Practica ACP & AF

Wanda Rodriguez

2023-01-03

library(pacman) p_load(“ade4”, “psych”, “car”,“matrixcalc”,“FactoMineR”, “factoextra”,“PerformanceAnalytics”,“GGally”,


“corrplot”,“corrr”,“funModeling”,“apaTables”)

library(readxl)
datos <- read_excel("Tabla 2.1.xlsx")
View(datos)
str(datos)

## tibble [48 x 15] (S3: tbl_df/tbl/data.frame)


## $ FL : num [1:48] 6 9 7 5 6 7 9 9 9 4 ...
## $ APP : num [1:48] 7 10 8 6 8 7 9 9 9 7 ...
## $ AA : num [1:48] 2 5 3 8 8 7 8 9 7 10 ...
## $ LA : num [1:48] 5 8 6 5 8 6 8 8 8 2 ...
## $ SC : num [1:48] 8 10 9 6 4 8 8 9 8 10 ...
## $ LC : num [1:48] 7 9 8 5 4 7 8 9 8 10 ...
## $ HON : num [1:48] 8 9 9 9 9 10 8 8 8 7 ...
## $ SMS : num [1:48] 8 10 7 2 5 5 8 8 5 10 ...
## $ EXP : num [1:48] 3 5 4 8 8 9 10 10 9 3 ...
## $ DRV : num [1:48] 8 9 9 4 5 6 8 9 8 10 ...
## $ AMB : num [1:48] 9 9 9 5 5 5 10 10 9 10 ...
## $ GSP : num [1:48] 7 8 8 8 8 8 8 9 8 10 ...
## $ POT : num [1:48] 5 8 6 7 8 6 9 9 8 9 ...
## $ KJ : num [1:48] 7 8 8 6 7 6 8 9 8 3 ...
## $ SUIT: num [1:48] 10 10 10 5 7 6 10 10 10 10 ...

#Analisis Descriptivo y de Correlacion


library(psych)
describe(datos)

## vars n mean sd median trimmed mad min max range skew kurtosis se
## FL 1 48 6.00 2.67 6.0 6.10 2.97 0 10 10 -0.24 -0.81 0.39
## APP 2 48 7.08 1.97 7.0 7.22 1.48 3 10 7 -0.74 -0.29 0.28
## AA 3 48 7.08 1.99 7.0 7.17 1.48 2 10 8 -0.37 -0.46 0.29
## LA 4 48 6.15 2.81 7.0 6.35 2.97 0 10 10 -0.60 -0.56 0.40
## SC 5 48 6.94 2.42 8.0 7.12 1.48 1 10 9 -0.72 -0.55 0.35
## LC 6 48 6.31 3.17 8.0 6.57 2.97 0 10 10 -0.63 -0.89 0.46
## HON 7 48 8.04 2.53 9.0 8.53 1.48 0 10 10 -1.72 2.50 0.37
## SMS 8 48 4.85 3.44 4.5 4.82 3.71 0 10 10 0.17 -1.35 0.50
## EXP 9 48 4.23 3.31 3.0 4.07 2.97 0 10 10 0.56 -1.12 0.48
## DRV 10 48 5.31 2.95 5.0 5.28 4.45 0 10 10 0.11 -1.29 0.43
## AMB 11 48 5.98 2.94 6.0 6.10 4.45 0 10 10 -0.22 -1.08 0.42

1
## GSP 12 48 6.25 3.04 7.0 6.50 2.22 0 10 10 -0.77 -0.52 0.44
## POT 13 48 5.69 3.18 6.0 5.82 2.97 0 10 10 -0.49 -1.01 0.46
## KJ 14 48 5.56 2.66 5.0 5.67 2.97 0 10 10 -0.27 -0.28 0.38
## SUIT 15 48 5.96 3.30 6.0 6.15 4.45 0 10 10 -0.24 -1.24 0.48

cor(datos)

## FL APP AA LA SC LC
## FL 1.00000000 0.2388057 0.044040889 0.306313037 0.092144656 0.22843205
## APP 0.23880573 1.0000000 0.123419296 0.379614151 0.430769427 0.37125894
## AA 0.04404089 0.1234193 1.000000000 0.001589766 0.001106763 0.07682449
## LA 0.30631304 0.3796142 0.001589766 1.000000000 0.302439887 0.48277493
## SC 0.09214466 0.4307694 0.001106763 0.302439887 1.000000000 0.80754502
## LC 0.22843205 0.3712589 0.076824494 0.482774928 0.807545017 1.00000000
## HON -0.10674947 0.3536910 -0.030269601 0.645408595 0.410090809 0.35584446
## SMS 0.27069919 0.4895490 0.054727421 0.361643880 0.799630538 0.81802080
## EXP 0.54837963 0.1409249 0.265585352 0.140723415 0.015125832 0.14720197
## DRV 0.34557633 0.3405493 0.093522030 0.393164148 0.704340067 0.69751518
## AMB 0.28464484 0.5496359 0.044065981 0.346555034 0.842122228 0.75754208
## GSP 0.33820196 0.5062987 0.197504552 0.502809305 0.721108973 0.88284865
## POT 0.36745292 0.5073769 0.290032151 0.605507554 0.671821239 0.77731617
## KJ 0.46720619 0.2840928 -0.323319352 0.685155768 0.482455962 0.52683562
## SUIT 0.58591822 0.3842084 0.140017368 0.326957419 0.250283416 0.41614467
## HON SMS EXP DRV AMB GSP
## FL -0.106749472 0.27069919 0.54837963 0.34557633 0.28464484 0.3382020
## APP 0.353690969 0.48954902 0.14092491 0.34054927 0.54963595 0.5062987
## AA -0.030269601 0.05472742 0.26558535 0.09352203 0.04406598 0.1975046
## LA 0.645408595 0.36164388 0.14072342 0.39316415 0.34655503 0.5028093
## SC 0.410090809 0.79963054 0.01512583 0.70434007 0.84212223 0.7211090
## LC 0.355844464 0.81802080 0.14720197 0.69751518 0.75754208 0.8828486
## HON 1.000000000 0.23990754 -0.15593849 0.28018499 0.21460636 0.3858218
## SMS 0.239907539 1.00000000 0.25541758 0.81473421 0.85952656 0.7821232
## EXP -0.155938495 0.25541758 1.00000000 0.33722821 0.19548192 0.2992682
## DRV 0.280184989 0.81473421 0.33722821 1.00000000 0.78032317 0.7140732
## AMB 0.214606359 0.85952656 0.19548192 0.78032317 1.00000000 0.7838707
## GSP 0.385821758 0.78212322 0.29926823 0.71407319 0.78387073 1.0000000
## POT 0.415657447 0.75360983 0.34833878 0.78840024 0.76886954 0.8758309
## KJ 0.448245522 0.56328419 0.21495316 0.61280767 0.54712558 0.5494076
## SUIT 0.002755617 0.55803585 0.69263617 0.62255406 0.43476824 0.5278163
## POT KJ SUIT
## FL 0.3674529 0.4672062 0.585918216
## APP 0.5073769 0.2840928 0.384208365
## AA 0.2900322 -0.3233194 0.140017368
## LA 0.6055076 0.6851558 0.326957419
## SC 0.6718212 0.4824560 0.250283416
## LC 0.7773162 0.5268356 0.416144671
## HON 0.4156574 0.4482455 0.002755617
## SMS 0.7536098 0.5632842 0.558035847
## EXP 0.3483388 0.2149532 0.692636173
## DRV 0.7884002 0.6128077 0.622554062
## AMB 0.7688695 0.5471256 0.434768242
## GSP 0.8758309 0.5494076 0.527816315
## POT 1.0000000 0.5393968 0.573873154
## KJ 0.5393968 1.0000000 0.395798842

2
## SUIT 0.5738732 0.3957988 1.000000000

corr.test(datos)

## Call:corr.test(x = datos)
## Correlation matrix
## FL APP AA LA SC LC HON SMS EXP DRV AMB GSP POT KJ
## FL 1.00 0.24 0.04 0.31 0.09 0.23 -0.11 0.27 0.55 0.35 0.28 0.34 0.37 0.47
## APP 0.24 1.00 0.12 0.38 0.43 0.37 0.35 0.49 0.14 0.34 0.55 0.51 0.51 0.28
## AA 0.04 0.12 1.00 0.00 0.00 0.08 -0.03 0.05 0.27 0.09 0.04 0.20 0.29 -0.32
## LA 0.31 0.38 0.00 1.00 0.30 0.48 0.65 0.36 0.14 0.39 0.35 0.50 0.61 0.69
## SC 0.09 0.43 0.00 0.30 1.00 0.81 0.41 0.80 0.02 0.70 0.84 0.72 0.67 0.48
## LC 0.23 0.37 0.08 0.48 0.81 1.00 0.36 0.82 0.15 0.70 0.76 0.88 0.78 0.53
## HON -0.11 0.35 -0.03 0.65 0.41 0.36 1.00 0.24 -0.16 0.28 0.21 0.39 0.42 0.45
## SMS 0.27 0.49 0.05 0.36 0.80 0.82 0.24 1.00 0.26 0.81 0.86 0.78 0.75 0.56
## EXP 0.55 0.14 0.27 0.14 0.02 0.15 -0.16 0.26 1.00 0.34 0.20 0.30 0.35 0.21
## DRV 0.35 0.34 0.09 0.39 0.70 0.70 0.28 0.81 0.34 1.00 0.78 0.71 0.79 0.61
## AMB 0.28 0.55 0.04 0.35 0.84 0.76 0.21 0.86 0.20 0.78 1.00 0.78 0.77 0.55
## GSP 0.34 0.51 0.20 0.50 0.72 0.88 0.39 0.78 0.30 0.71 0.78 1.00 0.88 0.55
## POT 0.37 0.51 0.29 0.61 0.67 0.78 0.42 0.75 0.35 0.79 0.77 0.88 1.00 0.54
## KJ 0.47 0.28 -0.32 0.69 0.48 0.53 0.45 0.56 0.21 0.61 0.55 0.55 0.54 1.00
## SUIT 0.59 0.38 0.14 0.33 0.25 0.42 0.00 0.56 0.69 0.62 0.43 0.53 0.57 0.40
## SUIT
## FL 0.59
## APP 0.38
## AA 0.14
## LA 0.33
## SC 0.25
## LC 0.42
## HON 0.00
## SMS 0.56
## EXP 0.69
## DRV 0.62
## AMB 0.43
## GSP 0.53
## POT 0.57
## KJ 0.40
## SUIT 1.00
## Sample Size
## [1] 48
## Probability values (Entries above the diagonal are adjusted for multiple tests.)
## FL APP AA LA SC LC HON SMS EXP DRV AMB GSP POT KJ SUIT
## FL 0.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.00 0.68 1.00 0.75 0.49 0.05 0.00
## APP 0.10 0.00 1.00 0.39 0.13 0.46 0.61 0.03 1.00 0.73 0.00 0.02 0.02 1.00 0.36
## AA 0.77 0.40 0.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.92 1.00
## LA 0.03 0.01 0.99 0.00 1.00 0.03 0.00 0.54 1.00 0.30 0.68 0.02 0.00 0.00 0.89
## SC 0.53 0.00 0.99 0.04 0.00 0.00 0.21 0.00 1.00 0.00 0.00 0.00 0.00 0.03 1.00
## LC 0.12 0.01 0.60 0.00 0.00 0.00 0.60 0.00 1.00 0.00 0.00 0.00 0.00 0.01 0.19
## HON 0.47 0.01 0.84 0.00 0.00 0.01 0.00 1.00 1.00 1.00 1.00 0.35 0.19 0.08 1.00
## SMS 0.06 0.00 0.71 0.01 0.00 0.00 0.10 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00
## EXP 0.00 0.34 0.07 0.34 0.92 0.32 0.29 0.08 0.00 0.75 1.00 1.00 0.67 1.00 0.00
## DRV 0.02 0.02 0.53 0.01 0.00 0.00 0.05 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.00
## AMB 0.05 0.00 0.77 0.02 0.00 0.00 0.14 0.00 0.18 0.00 0.00 0.00 0.00 0.00 0.12
## GSP 0.02 0.00 0.18 0.00 0.00 0.00 0.01 0.00 0.04 0.00 0.00 0.00 0.00 0.00 0.01

3
## POT 0.01 0.00 0.05 0.00 0.00 0.00 0.00 0.00 0.02 0.00 0.00 0.00 0.00 0.01 0.00
## KJ 0.00 0.05 0.02 0.00 0.00 0.00 0.00 0.00 0.14 0.00 0.00 0.00 0.00 0.00 0.29
## SUIT 0.00 0.01 0.34 0.02 0.09 0.00 0.99 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00
##
## To see confidence intervals of the correlations, print with the short=FALSE option

library(psych)
cor.plot(cor(datos),
main="Mapa de Calor",
diag=F,
show.legend = TRUE)

Mapa de Calor

FL 0.24 0.04 0.31 0.09 0.23 −0.11 0.27 0.55 0.35 0.28 0.34 0.37 0.47 0.59 1
APP 0.24 0.12 0.38 0.43 0.37 0.35 0.49 0.14 0.34 0.55 0.51 0.51 0.28 0.38
0.8
AA 0.04 0.12 0 0 0.08 −0.03 0.05 0.27 0.09 0.04 0.2 0.29 −0.32 0.14

LA 0.31 0.38 0 0.3 0.48 0.65 0.36 0.14 0.39 0.35 0.5 0.61 0.69 0.33 0.6
SC 0.09 0.43 0 0.3 0.81 0.41 0.8 0.02 0.7 0.84 0.72 0.67 0.48 0.25
0.4
LC 0.23 0.37 0.08 0.48 0.81 0.36 0.82 0.15 0.7 0.76 0.88 0.78 0.53 0.42

HON −0.11 0.35 −0.03 0.65 0.41 0.36 0.24 −0.16 0.28 0.21 0.39 0.42 0.45 0 0.2
SMS 0.27 0.49 0.05 0.36 0.8 0.82 0.24 0.26 0.81 0.86 0.78 0.75 0.56 0.56
0
EXP 0.55 0.14 0.27 0.14 0.02 0.15 −0.16 0.26 0.34 0.2 0.3 0.35 0.21 0.69

DRV 0.35 0.34 0.09 0.39 0.7 0.7 0.28 0.81 0.34 0.78 0.71 0.79 0.61 0.62 −0.2
AMB 0.28 0.55 0.04 0.35 0.84 0.76 0.21 0.86 0.2 0.78 0.78 0.77 0.55 0.43
−0.4
GSP 0.34 0.51 0.2 0.5 0.72 0.88 0.39 0.78 0.3 0.71 0.78 0.88 0.55 0.53

POT 0.37 0.51 0.29 0.61 0.67 0.78 0.42 0.75 0.35 0.79 0.77 0.88 0.54 0.57 −0.6
KJ 0.47 0.28 −0.32 0.69 0.48 0.53 0.45 0.56 0.21 0.61 0.55 0.55 0.54 0.4

SUIT 0.59 0.38 0.14 0.33 0.25 0.42 0 0.56 0.69 0.62 0.43 0.53 0.57 0.4 −0.8
−1
FL AA SC HON EXP AMB POT SUIT

#Prueba de Esfericidad de Barlett


library(rela)
cortest.bartlett(cor(datos),n=nrow(datos))

## $chisq
## [1] 645.3169
##
## $p.value
## [1] 1.256327e-78
##
## $df
## [1] 105

4
#Indicador Kaiser-Meyer-Olkinn KMO y MSA
KMO(datos)

## Kaiser-Meyer-Olkin factor adequacy


## Call: KMO(r = datos)
## Overall MSA = 0.78
## MSA for each item =
## FL APP AA LA SC LC HON SMS EXP DRV AMB GSP POT KJ SUIT
## 0.77 0.76 0.36 0.64 0.81 0.78 0.58 0.91 0.77 0.84 0.82 0.80 0.88 0.72 0.76

#Análisis Factorial con 6 variables con el Método de Componentes Principales


##Análisis Factorial sin rotación con función principal

library(psych)
facto.sin.rota <- principal(r=datos,
nfactors=2, #nfactors inicial=6
covar=F,#matriz de correlacion
rotate="none")
str(facto.sin.rota)

## List of 29
## $ values : num [1:15] 7.514 2.056 1.456 1.198 0.739 ...
## $ rotation : chr "none"
## $ n.obs : int 48
## $ communality : Named num [1:15] 0.576 0.344 0.128 0.415 0.761 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ loadings : ’loadings’ num [1:15, 1:2] 0.445 0.584 0.11 0.617 0.796 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "PC1" "PC2"
## $ fit : num 0.928
## $ fit.off : num 0.958
## $ fn : chr "principal"
## $ Call : language principal(r = datos, nfactors = 2, rotate = "none", covar = F)
## $ uniquenesses: Named num [1:15] 0.424 0.656 0.872 0.585 0.239 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ complexity : Named num [1:15] 1.82 1.01 1.21 1.18 1.39 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ chi : num 102
## $ EPVAL : num 0.0264
## $ R2 : Named num [1:2] 1 1
## ..- attr(*, "names")= chr [1:2] "PC1" "PC2"
## $ objective : num 5.17
## $ residual : num [1:15, 1:15] 0.4236 0.0098 -0.2139 0.1461 -0.0429 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## $ rms : num 0.1
## $ factors : int 2
## $ dof : num 76
## $ null.dof : num 105
## $ null.model : num 15.7
## $ criteria : Named num [1:3] 5.17 NA NA

5
## ..- attr(*, "names")= chr [1:3] "objective" "" ""
## $ STATISTIC : num 206
## $ PVAL : num 6.69e-14
## $ weights : num [1:15, 1:2] 0.0593 0.0777 0.0147 0.0821 0.106 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "PC1" "PC2"
## $ r.scores : num [1:2, 1:2] 1.00 -1.06e-15 -1.09e-15 1.00
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:2] "PC1" "PC2"
## .. ..$ : chr [1:2] "PC1" "PC2"
## $ Vaccounted : num [1:5, 1:2] 7.514 0.501 0.501 0.785 0.785 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "SS loadings" "Proportion Var" "Cumulative Var" "Proportion Explained" ...
## .. ..$ : chr [1:2] "PC1" "PC2"
## $ Structure : ’loadings’ num [1:15, 1:2] 0.445 0.584 0.11 0.617 0.796 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "PC1" "PC2"
## $ scores : num [1:48, 1:2] 0.471 1.276 0.805 -0.18 0.153 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : NULL
## .. ..$ : chr [1:2] "PC1" "PC2"
## - attr(*, "class")= chr [1:2] "psych" "principal"

# Autovalores
facto.sin.rota$values

## [1] 7.51379418 2.05630117 1.45581948 1.19789771 0.73915262 0.49457907


## [7] 0.35126183 0.30990202 0.25696154 0.18491037 0.15268036 0.09756308
## [13] 0.08881880 0.06463323 0.03572455

#Grafica de Valores Propios


## Primera forma
plot(facto.sin.rota$values,type="b",pch=20,col="blue",
main="Gráfico de sedimentación")
abline(h=1,lty=3,col="red")

6
Gráfico de sedimentación
6
facto.sin.rota$values

4
2
0

2 4 6 8 10 12 14

Index

## Segunda forma
eig.val <- facto.sin.rota$values
barplot(eig.val, names.arg=1:15,
main = "Gráfico de Sedimentación",
xlab = "Factores",
ylab = "Autovalores",
col ="steelblue")
lines(x = 1:15, eig.val,
type="b", pch=19, col = "red")

7
Gráfico de Sedimentación
7
6
5
Autovalores

4
3
2
1
0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Factores

#Comunalidades
facto.sin.rota$communality

## FL APP AA LA SC LC HON SMS


## 0.5764383 0.3437962 0.1275544 0.4152936 0.7613948 0.7802256 0.5258861 0.7918038
## EXP DRV AMB GSP POT KJ SUIT
## 0.7642057 0.7502918 0.7694912 0.8267942 0.8356624 0.5187627 0.7824944

#Cargas factoriales, Correlaciones factor, Variables


facto.sin.rota$loadings

##
## Loadings:
## PC1 PC2
## FL 0.445 0.615
## APP 0.584
## AA 0.110 0.340
## LA 0.617 -0.186
## SC 0.796 -0.357
## LC 0.863 -0.188
## HON 0.433 -0.581
## SMS 0.889
## EXP 0.367 0.793
## DRV 0.864
## AMB 0.872

8
## GSP 0.909
## POT 0.914
## KJ 0.711 -0.118
## SUIT 0.647 0.603
##
## PC1 PC2
## SS loadings 7.514 2.056
## Proportion Var 0.501 0.137
## Cumulative Var 0.501 0.638

#Grafico de Circulos de Correlaciones


library(ade4)
load.sin.rota <- facto.sin.rota$loadings[,1:2]
s.corcircle(load.sin.rota,grid=FALSE)

EXP

FL
SUIT

AA

DRV
POT
APP SMSGSP
KJ AMB
LA LC
SC

HON

#Analisis factorial con rotacion con función principal


library(psych)
facto.con.rota <- principal(r=datos,
nfactors=2,
x1
rotate="varimax")
str(facto.con.rota)

## List of 30
## $ values : num [1:15] 7.514 2.056 1.456 1.198 0.739 ...
## $ rotation : chr "varimax"

9
## $ n.obs : int 48
## $ communality : Named num [1:15] 0.576 0.344 0.128 0.415 0.761 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ loadings : ’loadings’ num [1:15, 1:2] 0.22055 0.56875 -0.00658 0.64394 0.86909 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "RC1" "RC2"
## $ fit : num 0.928
## $ fit.off : num 0.958
## $ fn : chr "principal"
## $ Call : language principal(r = datos, nfactors = 2, rotate = "varimax")
## $ uniquenesses: Named num [1:15] 0.424 0.656 0.872 0.585 0.239 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ complexity : Named num [1:15] 1.18 1.13 1 1 1.02 ...
## ..- attr(*, "names")= chr [1:15] "FL" "APP" "AA" "LA" ...
## $ chi : num 102
## $ EPVAL : num 0.0264
## $ R2 : Named num [1:2] 1 1
## ..- attr(*, "names")= chr [1:2] "RC1" "RC2"
## $ objective : num 5.17
## $ residual : num [1:15, 1:15] 0.4236 0.0098 -0.2139 0.1461 -0.0429 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## $ rms : num 0.1
## $ factors : int 2
## $ dof : num 76
## $ null.dof : num 105
## $ null.model : num 15.7
## $ criteria : Named num [1:3] 5.17 NA NA
## ..- attr(*, "names")= chr [1:3] "objective" "" ""
## $ STATISTIC : num 206
## $ PVAL : num 6.69e-14
## $ weights : num [1:15, 1:2] -0.0414 0.0815 -0.04 0.1071 0.1568 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "RC1" "RC2"
## $ r.scores : num [1:2, 1:2] 1.00 -1.23e-15 -1.27e-15 1.00
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:2] "RC1" "RC2"
## .. ..$ : chr [1:2] "RC1" "RC2"
## $ rot.mat : num [1:2, 1:2] 0.945 -0.326 0.326 0.945
## $ Vaccounted : num [1:5, 1:2] 6.934 0.462 0.462 0.725 0.725 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "SS loadings" "Proportion Var" "Cumulative Var" "Proportion Explained" ...
## .. ..$ : chr [1:2] "RC1" "RC2"
## $ Structure : ’loadings’ num [1:15, 1:2] 0.22055 0.56875 -0.00658 0.64394 0.86909 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:15] "FL" "APP" "AA" "LA" ...
## .. ..$ : chr [1:2] "RC1" "RC2"
## $ scores : num [1:48, 1:2] 0.5547 1.1995 0.8545 -0.2924 -0.0805 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : NULL
## .. ..$ : chr [1:2] "RC1" "RC2"

10
## - attr(*, "class")= chr [1:2] "psych" "principal"

facto.con.rota$values

## [1] 7.51379418 2.05630117 1.45581948 1.19789771 0.73915262 0.49457907


## [7] 0.35126183 0.30990202 0.25696154 0.18491037 0.15268036 0.09756308
## [13] 0.08881880 0.06463323 0.03572455

facto.con.rota$communality

## FL APP AA LA SC LC HON SMS


## 0.5764383 0.3437962 0.1275544 0.4152936 0.7613948 0.7802256 0.5258861 0.7918038
## EXP DRV AMB GSP POT KJ SUIT
## 0.7642057 0.7502918 0.7694912 0.8267942 0.8356624 0.5187627 0.7824944

facto.con.rota$loadings

##
## Loadings:
## RC1 RC2
## FL 0.221 0.726
## APP 0.569 0.143
## AA 0.357
## LA 0.644
## SC 0.869
## LC 0.877 0.104
## HON 0.599 -0.408
## SMS 0.854 0.250
## EXP 0.870
## DRV 0.795 0.344
## AMB 0.856 0.192
## GSP 0.870 0.265
## POT 0.853 0.328
## KJ 0.710 0.120
## SUIT 0.415 0.781
##
## RC1 RC2
## SS loadings 6.934 2.636
## Proportion Var 0.462 0.176
## Cumulative Var 0.462 0.638

head(facto.con.rota$scores)

## RC1 RC2
## [1,] 0.55471262 -0.164962790
## [2,] 1.19945563 0.435690953
## [3,] 0.85451021 -0.009232482
## [4,] -0.29243677 0.294503803
## [5,] -0.08046427 0.702334168
## [6,] 0.15830716 0.436762188

11
head(cbind(datos,
as.data.frame(scale(datos)),
facto.con.rota$scores ))

## FL APP AA LA SC LC HON SMS EXP DRV AMB GSP POT KJ SUIT FL APP
## 1 6 7 2 5 8 7 8 8 3 8 9 7 5 7 10 0.0000000 -0.04238674
## 2 9 10 5 8 10 9 9 10 5 9 9 8 8 8 10 1.1220199 1.48353605
## 3 7 8 3 6 9 8 9 7 4 9 9 8 6 8 10 0.3740066 0.46625419
## 4 5 6 8 5 6 5 9 2 8 4 5 8 7 6 5 -0.3740066 -0.55102767
## 5 6 8 8 8 4 4 9 5 8 5 5 8 8 7 7 0.0000000 0.46625419
## 6 7 7 7 6 8 7 10 5 9 6 5 8 6 6 6 0.3740066 -0.04238674
## AA LA SC LC HON SMS
## 1 -2.55758778 -0.4083963 0.4393996 0.2168737 -0.01643971 0.91465093
## 2 -1.04819171 0.6608594 1.2665046 0.8477791 0.37811332 1.49615086
## 3 -2.05445576 -0.0519777 0.8529521 0.5323264 0.37811332 0.62390096
## 4 0.46120435 -0.4083963 -0.3877055 -0.4140316 0.37811332 -0.82984886
## 5 0.46120435 0.6608594 -1.2148106 -0.7294843 0.37811332 0.04240104
## 6 -0.04192767 -0.0519777 0.4393996 0.2168737 0.77266635 0.04240104
## EXP DRV AMB GSP POT KJ SUIT
## 1 -0.37151453 0.9118031 1.0291042 0.2470963 -0.21596116 0.5410164 1.22464380
## 2 0.23298369 1.2510787 1.0291042 0.5765580 0.72641479 0.9173756 1.22464380
## 3 -0.06926542 1.2510787 1.0291042 0.5765580 0.09816416 0.9173756 1.22464380
## 4 1.13973102 -0.4452992 -0.3335717 0.5765580 0.41228948 0.1646572 -0.29037946
## 5 1.13973102 -0.1060236 -0.3335717 0.5765580 0.72641479 0.5410164 0.31562984
## 6 1.44198013 0.2332520 -0.3335717 0.5765580 0.09816416 0.1646572 0.01262519
## RC1 RC2
## 1 0.55471262 -0.164962790
## 2 1.19945563 0.435690953
## 3 0.85451021 -0.009232482
## 4 -0.29243677 0.294503803
## 5 -0.08046427 0.702334168
## 6 0.15830716 0.436762188

#Grafica de vriables sobre el primer plano de componentes


load <- facto.con.rota$loadings[,1:2]

plot(load, pch=20,
xlim=c(-1,1),
ylim=c(-1,1),
xlab="Factor 1",
ylab="Factor 2")
abline(h=0,lty=3)
abline(v=0,lty=3)
text(load,pos=1,labels=names(datos),cex=0.8)

12
1.0

EXP
FL SUIT
0.5

AA DRV
POT
Factor 2

GSP
SMS
AMB
0.0

APP KJ LC
LA
SC
−0.5

HON
−1.0

−1.0 −0.5 0.0 0.5 1.0

Factor 1

#Grafica de círculo de correlaciones


library(ade4)
load <- facto.con.rota$loadings[,1:2]
s.corcircle(load,grid=FALSE)

13
EXP
SUIT
FL

AA
DRV
POT
GSP
SMS
AMB
APPKJ LC
LA
SC

HON

fa.diagram(facto.con.rota)

x1

14
Components Analysis

LC
GSP
SC 0.9
0.9
AMB 0.9
0.9
SMS 0.9 RC1
0.9
POT 0.8
0.7
DRV 0.6
KJ 0.6
0.6
LA
HON
APP RC2
0.9
EXP 0.8
0.7
SUIT 0.4
FL
AA

#Grafica de Matriz de correlación entre variables y factores


library(psych)
salida.facto <- cbind(datos,facto.con.rota$scores)
cor.plot(cor(salida.facto),
main="Mapa de Calor",
diag=TRUE,number=F,
show.legend = TRUE)

15
Mapa de Calor

FL 1
APP 0.8
AA
LA 0.6
SC
LC 0.4
HON
SMS 0.2
EXP 0
DRV
AMB −0.2
GSP
POT −0.4
KJ
SUIT −0.6
RC1 −0.8
RC2
−1
FL AA SC HON EXP AMB POT SUIT RC2

library(GGally)

## Loading required package: ggplot2

##
## Attaching package: ’ggplot2’

## The following objects are masked from ’package:psych’:


##
## %+%, alpha

## Registered S3 method overwritten by ’GGally’:


## method from
## +.gg ggplot2

ggpairs(salida.facto)

16
FL APP AA LA SC LC HON SMS EXP DRV AMB GSP POT KJ SUIT RC1 RC2
0.125
0.100 Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:Corr:

FL APP AA LA SC LC HONSMSEXPDRVAMBGSPPOT KJ SUITRC1RC2


0.075
0.050
0.025
0.000 0.2390.044
108
Corr:0.306*
Corr:0.092
Corr:0.228
Corr:−0.107
Corr:0.271.
Corr:0.548***
Corr:0.346*
Corr:0.285*
Corr:0.338*
Corr:0.367*
Corr:0.467***
Corr:0.586***
Corr:0.221
Corr:0.726***
Corr:
6
4
10 0.1230.380**
Corr:0.431**
Corr:0.371**
Corr:0.354*
Corr:0.490***
Corr:0.141
Corr:0.341*
Corr:0.550***
Corr:0.506***
Corr:0.507***
Corr:0.284.
Corr:0.384**
Corr:0.569***
Corr:0.143
Corr:
8
6
4
2
10.0 0.0020.001
Corr:0.077
Corr:−0.030
Corr:0.055
Corr:0.266.
Corr:0.094
Corr:0.044
Corr:0.198
Corr:0.290*
Corr:−0.323*
Corr:0.140
Corr:−0.007
Corr:0.357*
Corr:
7.5
5.0
2.5
0.0
10.0 0.302*0.483***
Corr:0.645***
Corr:0.362*
Corr:0.141
Corr: 0.393**
Corr:0.347*
Corr:0.503***
Corr:0.606***
Corr:0.685***
Corr:0.327*
Corr:0.644***
Corr:0.025
Corr:
7.5
5.0
2.5
10.0 0.808***
0.410**
Corr:0.800***
Corr:0.015
Corr:0.704***
Corr:0.842***
Corr:0.721***
Corr:0.672***
Corr:0.482***
Corr:0.250.
Corr:0.869***
Corr:−0.078
Corr:
7.5
5.0
2.5
0.0
10.0 0.356*0.818***
Corr:0.147
Corr:0.698***
Corr:0.758***
Corr:0.883***
Corr:0.777***
Corr:0.527***
Corr:0.416**
Corr:0.877***
Corr:0.104
Corr:
7.5
5.0
2.5
0.0
10.0 0.240 −0.156
Corr:0.280.
Corr:0.215
Corr:0.386**
Corr:0.416**
Corr:0.448**
Corr:0.003
Corr:0.599***
Corr:−0.408**
Corr:
7.5
5.0
2.5
0.0
10.0 0.255.0.815***
Corr:0.860***
Corr:0.782***
Corr:0.754***
Corr:0.563***
Corr:0.558***
Corr:0.854***
Corr:0.250.
Corr:
7.5
5.0
2.5
0.0
10.0 0.337*0.195
Corr:0.299*
Corr:0.348*
Corr:0.215
Corr:0.693***
Corr:0.089
Corr:0.870***
Corr:
7.5
5.0
2.5
0.0
10.0 0.780***
0.714***
Corr:0.788***
Corr:0.613***
Corr:0.623***
Corr:0.795***
Corr:0.344*
Corr:
7.5
5.0
2.5
0.0
10.0 0.784***
0.769***
Corr:0.547***
Corr:0.435**
Corr:0.856***
Corr:0.192
Corr:
7.5
5.0
2.5
0.0
10.0 0.876***
0.549***
Corr:0.528***
Corr:0.870***
Corr:0.265.
Corr:
7.5
5.0
2.5
0.0
10.0 0.539***
0.574***
Corr:0.853***
Corr:0.328*
Corr:
7.5
5.0
2.5
0.0
10.0 0.396**0.710***
Corr:0.120
Corr:
7.5
5.0
2.5
0.0
1 0.415**0.781***
Corr:
−10
−2
−3
2
−0.000
1
0
−1
0.0
2.5
5.0
7.5
10.0468102468100.0
2.5
5.0
7.5
10.025.0
.57.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.00.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0
0.0
2.5
5.0
7.5
10.0−3
−2
−101 −1012

library(gplots)

##
## Attaching package: ’gplots’

## The following object is masked from ’package:stats’:


##
## lowess

library(polycor)

##
## Attaching package: ’polycor’

## The following object is masked from ’package:psych’:


##
## polyserial

library(DandEFA)
dandelion(facto.con.rota$loadings,bound = 0.5,mcex = c(-1,1),
palet = c("red","blue"))

17
APP
pos. load.

1:10
LA
neg. load.
SC
uniquenesses

APP
SU

LA
LC EX

IT
P Index SC
AA LC

1:10
FL HON
HON SM
KJ S

DR
T

AMB
GSP
PO

V
SM
KJ S communalities

APP
SU

LA
EX

DR
T

IT
SC
PO

P Index

V
AMB
GSP

AA LC

1:10
FL HON
SM
KJ S

DR
T

AMB
GSP
PO
SU

V
EX
IT

P Cum. Ratio
AA

0.8
Index 2.64
FL 6.93

0.4
0.0
F.1 F.2

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF,
and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the
output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)

## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00

Including Plots

You can also embed plots, for example:

18
800
600
pressure

400
200
0

0 50 100 150 200 250 300 350

temperature

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that
generated the plot.

19

You might also like