Valores propios

PcaEv(M=D,s=T) #s=T: Estandalizar (Necesario con unidades diferentes)

D=Ip('s4.txt') #Ejemplo sencillo´Puntaje de  4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
PcaEv() #Valor propio (varianza), Porcentaj, Porcentaje acumulado
##           Ev   V% V%(cum)
## Dim.1 1.9570 65.2    65.2
## Dim.2 0.9492 31.6    96.9
## Dim.3 0.0938  3.1   100.0
PcaEv(s=F) #s=F: Sin estandarilizar (Unidades iguales)
##            Ev   V% V%(cum)
## Dim.1 49.4511 71.4    71.4
## Dim.2 17.4946 25.3    96.7
## Dim.3  2.3043  3.3   100.0

Biplot

gPcaBp(M=D,lx=’‘,ly=’‘,s=0,c=’‘,a=T,w=F,f=12,m=1)
M:Martiz num:erica,lx,ly:R:otulos,s=[0]:Variable+Individuo/s=1:Variable/s=2:Individuo,
c:Asignar colores(ex:’V=>blue,..’),a:Flecha,w:Blanco y negro,f:Tamaño de letra,m:Multiplicador de variable
Colores: http://www.sthda.com/english/wiki/colors-in-r\ [b]lue(#039), [c]harcoal(#c30), [o]range(#f60), [p]urple(#coc), [r]ed (#f30)

D=Ip('s4.txt') #Ejemplo sencillo: Puntaje de  4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
gPcaBp() #Bilot

gPcaBp(s=1) #s=1:Dispersión de variables

gPcaBp(s=2) #s=2:Dispersión de individuos

gPcaBp(c='V=>#f60,V:v2=>orange,I:i3=>red') #c:Asignar colores

gPcaBp(c='V=>b',a=F) #a:Flecha=F

gPcaBp(c='V=>r',st=T) #st:Estandarizar=T

gPcaBp(c='V=>p',f=12) #f:Tamaño de letras=10

gPcaBp(lx='Eje-1 (65.2%)',ly='Eje-2 (31.6%)',w=T) #w=T:Blanco y negro

gChart(a=90)+gPcaBp()#Comparación:Distribución de frecuencia+Biplot de PCA

D=USArrests; Dt() #Datos:USArrests
## Class: data.frame / Rows: 50 / Columns: 4
##  
##             Murder Assault UrbanPop Rape
## Alabama     13.2   236     58       21.2
## Alaska      10.0   263     48       44.5
## Arizona      8.1   294     80       31.0
## Arkansas     8.8   190     50       19.5
## California   9.0   276     91       40.6
## Colorado     7.9   204     78       38.7
## Connecticut  3.3   110     77       11.1
## Delaware     5.9   238     72       15.8
## Florida     15.4   335     80       31.9
## Georgia     17.4   211     60       25.8
PcaEv() #Valores propios (varianza), Porcentaje, Porcentaje acumulado
##           Ev   V% V%(cum)
## Dim.1 2.4802 62.0    62.0
## Dim.2 0.9898 24.7    86.8
## Dim.3 0.3566  8.9    95.7
## Dim.4 0.1734  4.3   100.0
gPcaBp(c='V=>blue') #c:Color de rótulos=blue

gPcaBp(c='V=>blue',m=1.8,f=10) #Id.+m:Multiplicador de variable=1.8,f:Tamaño de letra=10

D=decathlon2; Dt(n=T) #Datos: decathlon2(+Rank,Points,Competition)
## Class: data.frame / Rows: 27 / Columns: 13
##  
##           X100m Long.jump Shot.put High.jump X400m X110m.hurdle Discus
## SEBRLE    11.04 7.58      14.83    2.07      49.81 14.69        43.75 
## CLAY      10.76 7.40      14.26    1.86      49.37 14.05        50.72 
## BERNARD   11.02 7.23      14.25    1.92      48.93 14.99        40.87 
## YURKOV    11.34 7.09      15.19    2.10      50.42 15.31        46.26 
## ZSIVOCZKY 11.13 7.30      13.48    2.01      48.62 14.17        45.67 
## McMULLEN  10.83 7.31      13.76    2.13      49.91 14.38        44.41 
## MARTINEAU 11.64 6.81      14.57    1.95      50.14 14.93        47.60 
## HERNU     11.37 7.56      14.41    1.86      51.10 15.06        44.99 
## BARRAS    11.33 6.97      14.09    1.95      49.48 14.48        42.10 
## NOOL      11.33 7.27      12.68    1.98      49.20 15.29        37.92 
##           Pole.vault Javeline X1500m Rank Points Competition
## SEBRLE    5.02       63.19    291.7   1   8217   Decastar   
## CLAY      4.92       60.15    301.5   2   8122   Decastar   
## BERNARD   5.32       62.77    280.1   4   8067   Decastar   
## YURKOV    4.72       63.44    276.4   5   8036   Decastar   
## ZSIVOCZKY 4.42       55.37    268.0   7   8004   Decastar   
## McMULLEN  4.42       56.37    285.1   8   7995   Decastar   
## MARTINEAU 4.92       52.33    262.1   9   7802   Decastar   
## HERNU     4.82       57.19    285.1  10   7733   Decastar   
## BARRAS    4.72       55.40    282.0  11   7708   Decastar   
## NOOL      4.62       57.44    266.6  12   7651   Decastar   
## 
## Row names: 1.SEBRLE 2.CLAY 3.BERNARD 4.YURKOV 5.ZSIVOCZKY 6.McMULLEN 7.MARTINEAU 8.HERNU 9.BARRAS 10.NOOL
##  
## Column names: 1.X100m 2.Long.jump 3.Shot.put 4.High.jump 5.X400m 6.X110m.hurdle 7.Discus 8.Pole.vault 9.Javeline 10.X1500m 11.Rank 12.Points 13.Competition
D=D[1:15,1:10]; Dt() #Filas:1-15, Columnas:1-10
## Class: data.frame / Rows: 15 / Columns: 10
##  
##           X100m Long.jump Shot.put High.jump X400m X110m.hurdle Discus
## SEBRLE    11.04 7.58      14.83    2.07      49.81 14.69        43.75 
## CLAY      10.76 7.40      14.26    1.86      49.37 14.05        50.72 
## BERNARD   11.02 7.23      14.25    1.92      48.93 14.99        40.87 
## YURKOV    11.34 7.09      15.19    2.10      50.42 15.31        46.26 
## ZSIVOCZKY 11.13 7.30      13.48    2.01      48.62 14.17        45.67 
## McMULLEN  10.83 7.31      13.76    2.13      49.91 14.38        44.41 
## MARTINEAU 11.64 6.81      14.57    1.95      50.14 14.93        47.60 
## HERNU     11.37 7.56      14.41    1.86      51.10 15.06        44.99 
## BARRAS    11.33 6.97      14.09    1.95      49.48 14.48        42.10 
## NOOL      11.33 7.27      12.68    1.98      49.20 15.29        37.92 
##           Pole.vault Javeline X1500m
## SEBRLE    5.02       63.19    291.7 
## CLAY      4.92       60.15    301.5 
## BERNARD   5.32       62.77    280.1 
## YURKOV    4.72       63.44    276.4 
## ZSIVOCZKY 4.42       55.37    268.0 
## McMULLEN  4.42       56.37    285.1 
## MARTINEAU 4.92       52.33    262.1 
## HERNU     4.82       57.19    285.1 
## BARRAS    4.72       55.40    282.0 
## NOOL      4.62       57.44    266.6
PcaEv() #Valores propios (varianza), Porcentaje, Porcentaje acumulado
##            Ev   V% V%(cum)
## Dim.1  4.7291 47.3    47.3
## Dim.2  1.9975 20.0    67.3
## Dim.3  1.0856 10.9    78.1
## Dim.4  0.7539  7.5    85.7
## Dim.5  0.6559  6.6    92.2
## Dim.6  0.3021  3.0    95.2
## Dim.7  0.2253  2.3    97.5
## Dim.8  0.1417  1.4    98.9
## Dim.9  0.0714  0.7    99.6
## Dim.10 0.0374  0.4   100.0
gPcaBp() #Bilpot

gPcaBp(c='V=>b') #c:Color de rótulos=blue

gPcaBp(c='V=>b',m=3.5) #Id.+m:Multiplicador de variable=3.5

Grp=decathlon2[1:15,13]; G #Grupos:Competition

gPcaGp(D,Grp,lg='Grupo') #ACP-Grupo

gPcaGp(D,Grp,lg='Grupo',c='forestgreen,red') #Id.c:Color de drupo

—–

Referencia

Portada

(Hiroto Ueda, Universidad de Tokio, 2022)