## Warning: package 'readxl' was built under R version 4.2.3
## # A tibble: 41 × 7
##    Ciudad          SO2  Temp   Man   Pop  Wind  Rain
##    <chr>         <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 Phoenix          10  70.3   213   582   6    7.05
##  2 Little Rock      13  61      91   132   8.2 48.5 
##  3 San Francisco    12  56.7   453   716   8.7 20.7 
##  4 Denver           17  51.9   454   515   9   13.0 
##  5 Hartford         56  49.1   412   158   9   43.4 
##  6 Wilmington       36  54      80    80   9   40.2 
##  7 Washington       29  57.3   434   757   9.3 38.9 
##  8 Jacksonville     14  68.4   136   529   8.8 54.5 
##  9 Miami            10  75.5   207   335   9   59.8 
## 10 Atlanta          24  61.5   368   497   9.1 48.3 
## # ℹ 31 more rows
## [1] 41  7

Análisis de componentes principales

ACP utilizando matriz de correlaciones

## Call:
## princomp(x = data_series2[, -1], cor = TRUE)
## 
## Standard deviations:
##    Comp.1    Comp.2    Comp.3    Comp.4    Comp.5    Comp.6 
## 1.6182426 1.1824721 0.9704808 0.8883957 0.4758577 0.1597823 
## 
##  6  variables and  41 observations.
## Importance of components:
##                           Comp.1    Comp.2    Comp.3    Comp.4     Comp.5
## Standard deviation     1.6182426 1.1824721 0.9704808 0.8883957 0.47585770
## Proportion of Variance 0.4364515 0.2330400 0.1569722 0.1315411 0.03774009
## Cumulative Proportion  0.4364515 0.6694915 0.8264637 0.9580048 0.99574494
##                             Comp.6
## Standard deviation     0.159782280
## Proportion of Variance 0.004255063
## Cumulative Proportion  1.000000000

Matriz de correlacion

##              SO2        Temp         Man         Pop        Wind        Rain
## SO2   1.00000000 -0.43360020  0.64476873  0.49377958  0.09469045  0.05429434
## Temp -0.43360020  1.00000000 -0.19004216 -0.06267813 -0.34973963  0.38625342
## Man   0.64476873 -0.19004216  1.00000000  0.95526935  0.23794683 -0.03241688
## Pop   0.49377958 -0.06267813  0.95526935  1.00000000  0.21264375 -0.02611873
## Wind  0.09469045 -0.34973963  0.23794683  0.21264375  1.00000000 -0.01299438
## Rain  0.05429434  0.38625342 -0.03241688 -0.02611873 -0.01299438  1.00000000

Cargas de cada componente y matriz de correlación

Cargas de cada componente

## Importance of components:
##                           Comp.1    Comp.2    Comp.3    Comp.4     Comp.5
## Standard deviation     1.6182426 1.1824721 0.9704808 0.8883957 0.47585770
## Proportion of Variance 0.4364515 0.2330400 0.1569722 0.1315411 0.03774009
## Cumulative Proportion  0.4364515 0.6694915 0.8264637 0.9580048 0.99574494
##                             Comp.6
## Standard deviation     0.159782280
## Proportion of Variance 0.004255063
## Cumulative Proportion  1.000000000
## 
## Loadings:
##      Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## SO2   0.482         0.109  0.614  0.596  0.149
## Temp -0.289  0.646        -0.386  0.589       
## Man   0.578  0.225  0.106 -0.179 -0.130 -0.745
## Pop   0.533  0.290  0.115 -0.354 -0.266  0.650
## Wind  0.246 -0.288 -0.811 -0.328  0.301       
## Rain         0.603 -0.550  0.457 -0.345
## 
## Loadings:
##      Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## SO2   0.482         0.109  0.614  0.596  0.149
## Temp -0.289  0.646        -0.386  0.589       
## Man   0.578  0.225  0.106 -0.179 -0.130 -0.745
## Pop   0.533  0.290  0.115 -0.354 -0.266  0.650
## Wind  0.246 -0.288 -0.811 -0.328  0.301       
## Rain         0.603 -0.550  0.457 -0.345       
## 
##                Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## SS loadings     1.000  1.000  1.000  1.000  1.000  1.000
## Proportion Var  0.167  0.167  0.167  0.167  0.167  0.167
## Cumulative Var  0.167  0.333  0.500  0.667  0.833  1.000
##            Comp.1     Comp.2      Comp.3      Comp.4       Comp.5      Comp.6
##  [1,] -1.69854799  0.3307039  3.35431015 -1.58693052  0.903326659  0.08599409
##  [2,] -1.68933620  0.9179076 -0.04569071  0.43169616 -0.311486385 -0.19138215
##  [3,] -0.34960289 -0.5764095  1.13202346 -1.05216604 -0.114573312  0.01242862
##  [4,] -0.13580606 -1.5655185  1.26940024 -0.90901629  0.004302937 -0.15911041
##  [5,]  0.21618124 -0.3787419 -0.08849580  1.70565487  0.048647297 -0.25450455
##  [6,] -0.79517292 -0.3026105 -0.07463581  0.94367037  0.145312121 -0.04732920
##  [7,] -0.01467187  0.3402769  0.01393394 -0.07655339 -0.056181027  0.19200619
##  [8,] -1.48481923  1.9944547 -0.52016758 -0.10773050  0.080505710  0.17829770
##  [9,] -1.96149572  2.7961387 -0.87487832 -0.33687873  0.521556105 -0.19267563
## [10,] -0.69495892  1.0845492 -0.37289434  0.16441644 -0.024983209 -0.06980895
## [11,]  7.61666514  1.9097665  0.99735457 -0.55425955 -0.056695352 -0.17515390
## [12,]  0.15138296 -0.2380671 -0.26955484  0.09849411 -0.382518877  0.29649500
## [13,] -0.40609554 -1.6500198 -0.99478259 -0.25313309 -0.069564671 -0.01704810
## [14,] -0.54451589 -1.2500608 -1.80668872 -1.31536171  0.613547645 -0.03371453
## [15,] -0.42805758  0.4700481  0.32013083  0.58779673 -0.399417916  0.19934558
## [16,] -1.75520000  2.1209090 -0.44407667  0.03091434 -0.147529393 -0.13993073
## [17,]  0.82557400  0.3769788 -0.14073602  0.39667201  0.095349712  0.23229938
## [18,]  1.95854518 -0.2552045  0.17007870 -0.68659489 -0.605846946  0.28819436
## [19,]  1.11660054 -1.7440801 -0.18283511 -0.21943948 -0.588926210 -0.10089997
## [20,] -0.36700082 -0.3256206 -0.45203695 -0.38763508 -0.338685407 -0.09738829
## [21,]  0.88590019  0.1287327  0.19437268  0.52371766  0.637448000 -0.23540470
## [22,] -0.40157988 -1.2967451 -0.74084435 -0.53946435 -0.070495865  0.01275419
## [23,] -1.11900548 -1.6828635  1.45073896 -1.21393005  0.608484581  0.02003326
## [24,] -0.32285541 -1.1786361  0.36259246  1.31922488  0.028045542  0.13333385
## [25,]  0.26361022 -1.5541625 -1.86950128 -0.63626402 -0.470178365 -0.12303874
## [26,] -0.64483584  0.3467480  1.16131605  0.63966777 -0.821098025 -0.23780188
## [27,]  1.93485949 -0.5911341 -0.50489251  0.58161019  0.568149762 -0.30021204
## [28,] -0.32917419 -0.3216126  0.36940317  0.43471569 -0.564882569  0.16942213
## [29,]  3.38980370  1.2662450  0.43753533 -0.04392728 -0.067238564  0.13424337
## [30,]  0.65311965 -0.5485146  0.11391232  1.19034489  0.428675269  0.27620631
## [31,]  1.20083307 -0.6146977 -0.80220219  2.27616058  1.465815945  0.11847117
## [32,] -0.89140752  1.1427817 -0.51169622 -0.27386006 -0.429875914  0.02641683
## [33,] -1.07128777  0.9465552  0.35514062  0.36628956 -0.494258603 -0.04222737
## [34,] -0.19622659  0.7622427 -0.73233339 -1.69556467  0.503663934 -0.13550362
## [35,]  0.06456567  1.8936451 -1.13486704 -1.57692452  0.167069060  0.18944335
## [36,] -0.58240476 -1.7539663  1.25291865 -0.10005961  0.315020932 -0.04905692
## [37,] -0.63383350  0.1940580 -1.13637206  0.18057175  0.553585890  0.15057172
## [38,] -1.09046339  0.5914529  0.66897002  0.71772267 -0.295594520 -0.05093688
## [39,] -0.01356076 -0.3830201 -0.14404990  0.38897266 -0.425307593  0.03673172
## [40,] -1.44207636  0.3119773  1.31448208  1.36743374 -0.417305885 -0.06061559
## [41,]  0.78635202 -1.7144861 -1.09438185 -0.78005323 -0.535862495 -0.03894467

Biplot análisis de componentes principales

Relación entre todas las variables.

Método matricial, ocupando eigen.

T1cp<-princomp(data_series2[,-1],cor=TRUE) summary(T1cp) cov1<-cor(data_series2[,-1]) ei1<-eigen(cov1) ei1 val1<-round(ei1\(values[1:6]/sum(ei1\)values),4) val1 ## Peso de cada variable

## Importance of components:
##                           Comp.1    Comp.2    Comp.3    Comp.4     Comp.5
## Standard deviation     1.6182426 1.1824721 0.9704808 0.8883957 0.47585770
## Proportion of Variance 0.4364515 0.2330400 0.1569722 0.1315411 0.03774009
## Cumulative Proportion  0.4364515 0.6694915 0.8264637 0.9580048 0.99574494
##                             Comp.6
## Standard deviation     0.159782280
## Proportion of Variance 0.004255063
## Cumulative Proportion  1.000000000
## eigen() decomposition
## $values
## [1] 2.61870900 1.39824026 0.94183296 0.78924686 0.22644055 0.02553038
## 
## $vectors
##             [,1]        [,2]        [,3]       [,4]       [,5]         [,6]
## [1,]  0.48202425  0.03597091 -0.10886658  0.6140010 -0.5961241 -0.148813741
## [2,] -0.28866577  0.64556679 -0.05689778 -0.3857221 -0.5890272  0.030720007
## [3,]  0.57805937  0.22549418 -0.10599379 -0.1789520  0.1301198  0.744855742
## [4,]  0.53289744  0.29042373 -0.11476561 -0.3544397  0.2664572 -0.649520024
## [5,]  0.24614583 -0.28826301  0.81114336 -0.3281215 -0.3008086 -0.014614826
## [6,] -0.07486395  0.60304269  0.55004666  0.4570626  0.3453499  0.003289364
## [1] 0.4365 0.2330 0.1570 0.1315 0.0377 0.0043

ESTATING ANALYTICS

CONSTRUYAMOS ALGO JUNTOS