Use R!
require(lattice)
## Loading required package: lattice
library(psych)
library(GPArotation)
library(corrplot)
## corrplot 0.84 loaded
library(vegan)
## Loading required package: permute
## This is vegan 2.5-2
library(ade4)
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(factoextra)
## Welcome! Related Books: `Practical Guide To Cluster Analysis in R` at https://goo.gl/13EFCZ
suelo = read.table('regiones.txt', head=TRUE)
head(suelo)
## este norte altitud ca20 mg20 ctc20 ca40 mg40 ctc40 muestra region
## 1 5710 4829 6.10 52 18 106.0 40 16 86.3 a1 R3
## 2 5727 4875 6.05 57 20 131.1 49 21 123.1 a2 R3
## 3 5745 4922 6.30 72 22 114.6 63 22 101.7 a3 R3
## 4 5764 4969 6.60 74 11 114.4 74 12 95.6 a4 R3
## 5 5781 5015 6.60 68 34 124.4 44 36 106.3 a5 R3
## 6 5799 5062 5.75 45 27 132.9 27 22 105.3 a6 R3
ACP<-suelo[,c(-1,-2,-3,-10,-11)]
head(ACP)
## ca20 mg20 ctc20 ca40 mg40 ctc40
## 1 52 18 106.0 40 16 86.3
## 2 57 20 131.1 49 21 123.1
## 3 72 22 114.6 63 22 101.7
## 4 74 11 114.4 74 12 95.6
## 5 68 34 124.4 44 36 106.3
## 6 45 27 132.9 27 22 105.3
(S <- round(cov(ACP),2))
## ca20 mg20 ctc20 ca40 mg40 ctc40
## ca20 122.10 22.78 37.22 113.05 30.67 27.98
## mg20 22.78 39.28 25.74 18.26 28.51 9.00
## ctc20 37.22 25.74 335.64 44.31 31.93 313.39
## ca40 113.05 18.26 44.31 182.22 41.49 105.72
## mg40 30.67 28.51 31.93 41.49 47.88 55.62
## ctc40 27.98 9.00 313.39 105.72 55.62 497.31
R <- round(cor(ACP), 2)
R
## ca20 mg20 ctc20 ca40 mg40 ctc40
## ca20 1.00 0.33 0.18 0.76 0.40 0.11
## mg20 0.33 1.00 0.22 0.22 0.66 0.06
## ctc20 0.18 0.22 1.00 0.18 0.25 0.77
## ca40 0.76 0.22 0.18 1.00 0.44 0.35
## mg40 0.40 0.66 0.25 0.44 1.00 0.36
## ctc40 0.11 0.06 0.77 0.35 0.36 1.00
(z <- scale(ACP))
## ca20 mg20 ctc20 ca40 mg40
## [1,] 0.12032852 -1.4858567 -1.431861279 -0.3708156595 -1.40808260
## [2,] 0.57282441 -1.1667585 -0.061810691 0.2959075855 -0.68547140
## [3,] 1.93031208 -0.8476603 -0.962441556 1.3330326332 -0.54094916
## [4,] 2.11131043 -2.6027005 -0.973358293 2.1479165993 -1.98617155
## [5,] 1.56831537 1.0669289 -0.427521406 -0.0744942173 1.48236218
## [6,] -0.51316573 -0.0499148 0.036439949 -1.3338603467 -0.54094916
## [7,] -0.33216737 -0.0499148 -0.198269913 -0.7412174623 -0.10738245
## [8,] -0.15116902 0.4287325 -0.580355734 -0.7412174623 -0.10738245
## [9,] -1.14665998 -0.3690130 -0.569438997 -1.1856996256 0.32618427
## [10,] 0.21082769 -0.2094639 -0.989733400 -1.6301817890 -1.11903812
## [11,] 0.84432194 1.2264780 -0.121852749 1.0367111910 1.19331770
## [12,] -0.33216737 -0.2094639 -3.047538466 -1.7042621495 0.61522875
## [13,] -1.50865669 1.0669289 -2.458034627 -0.9634585440 0.32618427
## [14,] 0.48232523 -0.8476603 -0.711356587 -0.2967352990 -0.54094916
## [15,] 1.38731701 -1.0072094 -0.454813250 1.2589522727 -0.68547140
## [16,] 0.21082769 0.4287325 -0.056352322 0.5922290277 1.77140666
## [17,] -0.69416409 -0.5285621 -0.170978069 0.2218272249 0.32618427
## [18,] -0.78466327 -1.0072094 -0.132769486 -1.0375389045 -0.39642692
## [19,] -0.15116902 -0.2094639 -0.203728282 -0.5189763806 -0.25190468
## [20,] -0.51316573 0.4287325 0.140148957 -0.1485745779 0.61522875
## [21,] 0.21082769 1.3860271 0.560443361 1.3330326332 1.48236218
## [22,] -1.14665998 -0.5285621 -0.640397792 -0.5930567412 -0.39642692
## [23,] -0.33216737 -0.0499148 -0.673148005 -0.2967352990 0.18166203
## [24,] -1.41815751 -0.2094639 -0.842357440 -1.0375389045 -0.68547140
## [25,] 0.84432194 0.4287325 -0.924232973 1.4071129938 0.90427323
## [26,] -0.51316573 -1.1667585 -1.644737665 -0.5189763806 0.47070651
## [27,] 0.84432194 -0.5285621 0.254774704 1.0367111910 -0.25190468
## [28,] 0.93482112 -1.1667585 -2.627244063 2.5183184021 -1.11903812
## [29,] 0.66332358 1.0669289 0.773319747 -0.1485745779 1.33783994
## [30,] -0.60366491 -0.8476603 1.128113724 -0.5189763806 -0.68547140
## [31,] -0.06066984 -0.3690130 0.325733499 0.1477468643 -0.25190468
## [32,] -0.33216737 -0.6881112 -0.154602962 -0.0004138568 -0.39642692
## [33,] -0.15116902 0.7478307 -0.231020126 -0.5930567412 0.18166203
## [34,] -0.42266655 0.4287325 0.112857113 -1.3338603467 0.18166203
## [35,] -0.69416409 -0.3690130 -0.558522259 -0.9634585440 0.32618427
## [36,] 0.48232523 1.2264780 -0.580355734 -0.8893781834 -0.39642692
## [37,] -0.69416409 0.9073798 -1.251735106 0.8144701093 0.32618427
## [38,] -0.06066984 -0.3690130 -1.448236385 -1.1116192651 0.03713979
## [39,] 0.93482112 0.4287325 0.560443361 0.9626308304 0.75975099
## [40,] 0.57282441 0.2691834 1.548408127 0.4440683066 -0.39642692
## [41,] 0.57282441 -0.5285621 2.661915378 0.6663093882 -0.10738245
## [42,] -0.78466327 -1.0072094 2.236162605 -1.4079407073 -0.97451588
## [43,] -0.87516244 -0.8476603 2.077869908 -1.4079407073 -1.26356036
## [44,] 0.30132687 0.7478307 -0.012685371 0.2218272249 0.75975099
## [45,] -0.42266655 0.7478307 -0.165519700 -1.2597799862 0.18166203
## [46,] -0.06066984 1.5455762 -0.389312824 -0.8152978229 0.18166203
## [47,] -0.69416409 0.2691834 -1.562862132 -1.1116192651 0.47070651
## [48,] 1.93031208 0.4287325 -1.459153123 1.2589522727 0.47070651
## [49,] 0.48232523 0.4287325 -2.305200299 -1.4820210679 -1.11903812
## [50,] -1.14665998 -1.1667585 -1.388194328 -1.1856996256 -0.82999364
## [51,] 1.20631865 -0.5285621 -1.087984040 1.9256755177 -0.68547140
## [52,] 0.48232523 -0.6881112 -0.280145446 0.8144701093 -0.54094916
## [53,] 1.56831537 1.0669289 0.866112018 1.7034344360 1.04879547
## [54,] 0.93482112 0.4287325 0.342108606 -0.1485745779 0.47070651
## [55,] -0.06066984 -1.3263076 0.091023637 -0.2967352990 -0.54094916
## [56,] -0.33216737 -0.2094639 -0.083644167 -0.2967352990 -0.68547140
## [57,] 0.66332358 0.5882816 0.091023637 0.7403897488 0.47070651
## [58,] 0.21082769 1.7051253 0.374858819 -0.7412174623 0.61522875
## [59,] -0.33216737 1.0669289 -0.394771193 -0.5189763806 0.75975099
## [60,] -1.32765833 0.2691834 -1.317235532 -0.8893781834 0.03713979
## [61,] -0.87516244 1.0669289 -0.094560904 -0.4448960201 -0.10738245
## [62,] 1.83981290 -0.0499148 0.336650237 1.1107915516 1.33783994
## [63,] -0.60366491 -0.8476603 0.107398744 -0.0004138568 -1.11903812
## [64,] 1.56831537 -1.0072094 -0.776857014 1.6293540754 -0.25190468
## [65,] 1.47781619 -0.8476603 -0.214645020 0.7403897488 -0.39642692
## [66,] 0.66332358 -0.3690130 0.325733499 0.3699879460 -0.68547140
## [67,] 0.12032852 -0.0499148 0.047356686 -0.9634585440 -1.55260484
## [68,] 1.20631865 -0.6881112 0.222024490 0.7403897488 0.18166203
## [69,] 0.30132687 0.2691834 -0.072727429 -1.4820210679 -1.55260484
## [70,] 0.12032852 0.9073798 0.129232220 0.3699879460 1.04879547
## [71,] -0.42266655 1.8646744 -0.143686224 -1.1856996256 0.75975099
## [72,] -0.96566162 0.9073798 -0.241936864 -1.7783425101 -0.54094916
## [73,] -1.05616080 -0.3690130 -1.382735959 -0.5930567412 -0.10738245
## [74,] 1.02532030 -0.6881112 1.057154928 -1.1116192651 -1.26356036
## [75,] -0.15116902 -0.6881112 0.456734352 -0.0004138568 4.08376248
## [76,] 0.66332358 -1.0072094 -0.804148858 0.6663093882 -0.82999364
## [77,] 1.38731701 -0.3690130 0.009148104 1.1848719121 0.18166203
## [78,] -0.06066984 -0.0499148 0.145607326 -0.3708156595 -0.39642692
## [79,] -0.06066984 -0.6881112 -0.176436438 -0.0004138568 -0.10738245
## [80,] 0.93482112 -0.0499148 0.702360951 -0.9634585440 -0.39642692
## [81,] 0.93482112 1.2264780 1.149947199 0.8885504699 0.75975099
## [82,] 0.66332358 1.2264780 0.991654502 0.8885504699 0.75975099
## [83,] -0.96566162 -0.0499148 -1.055233826 -0.0004138568 -1.26356036
## [84,] -0.60366491 0.2691834 0.052815055 -1.6301817890 -1.55260484
## [85,] -1.59915587 -1.3263076 0.096482006 -0.9634585440 -1.11903812
## [86,] -2.05165176 -1.3263076 1.209989257 -0.0744942173 -0.54094916
## [87,] 0.75382276 -0.5285621 2.285287925 -0.0004138568 -0.82999364
## [88,] 1.38731701 -0.6881112 -0.214645020 1.1107915516 -0.54094916
## [89,] 1.29681783 -0.6881112 -0.307437291 1.3330326332 0.18166203
## [90,] 0.30132687 -0.2094639 -0.307437291 -1.3338603467 -1.26356036
## [91,] 1.38731701 0.9073798 1.068071666 1.1107915516 0.32618427
## [92,] 1.83981290 0.9073798 1.133572093 1.7034344360 0.61522875
## [93,] 1.65881454 1.0669289 0.615027049 1.7034344360 1.19331770
## [94,] 0.75382276 1.5455762 0.795153222 1.0367111910 1.77140666
## [95,] -0.69416409 1.0669289 -0.072727429 -1.3338603467 -2.13069379
## [96,] -0.87516244 -0.0499148 -0.793232120 -0.4448960201 -1.26356036
## [97,] -1.96115258 -0.6881112 1.477449332 -1.2597799862 0.03713979
## [98,] 1.93031208 0.9073798 1.848618415 1.5552737149 0.90427323
## [99,] -0.15116902 -0.3690130 0.129232220 0.5922290277 -0.82999364
## [100,] 0.21082769 0.1096343 0.849736911 0.5922290277 0.32618427
## [101,] 0.66332358 1.3860271 0.500401303 0.6663093882 1.62688442
## [102,] 0.39182605 2.3433218 0.260233073 0.3699879460 1.48236218
## [103,] 0.30132687 2.1837727 0.145607326 0.5922290277 2.20497338
## [104,] 0.48232523 1.2264780 0.189274277 0.8144701093 1.91592890
## [105,] -0.33216737 1.3860271 0.282066548 -1.6301817890 -0.54094916
## [106,] -0.69416409 1.2264780 0.866112018 -0.5189763806 1.04879547
## [107,] -0.24166820 1.2264780 -0.411146299 -0.2226549384 0.61522875
## [108,] -0.33216737 0.4287325 0.336650237 -0.2967352990 -0.10738245
## [109,] -1.14665998 -1.1667585 -1.857614051 -0.1485745779 -1.55260484
## [110,] 0.66332358 -0.8476603 -0.280145446 0.7403897488 -0.54094916
## [111,] 0.21082769 -0.3690130 -0.001768633 0.5922290277 0.32618427
## [112,] 0.12032852 0.4287325 0.429442508 0.5922290277 0.47070651
## [113,] 0.48232523 1.5455762 0.413067401 -0.0744942173 0.47070651
## [114,] 0.21082769 1.3860271 0.380317188 0.5922290277 1.62688442
## [115,] -0.06066984 0.9073798 -0.274687077 0.8144701093 1.19331770
## [116,] -0.33216737 0.5882816 0.303900024 0.4440683066 0.90427323
## [117,] -0.69416409 1.3860271 0.243857966 -1.7783425101 -0.82999364
## [118,] -0.96566162 0.2691834 -0.689523112 -0.7412174623 -0.10738245
## [119,] -1.14665998 -0.5285621 -0.553063890 -1.6301817890 -1.55260484
## [120,] 0.66332358 -0.2094639 -0.220103389 0.9626308304 -0.25190468
## [121,] 0.39182605 -0.5285621 0.047356686 0.9626308304 -0.10738245
## [122,] 1.29681783 0.2691834 -0.187353175 1.5552737149 -0.54094916
## [123,] 0.21082769 0.1096343 0.183815908 0.2959075855 0.18166203
## [124,] 0.66332358 -0.0499148 0.003689735 0.8144701093 0.32618427
## [125,] -0.78466327 -0.8476603 -0.203728282 -0.3708156595 -1.11903812
## [126,] -0.42266655 -1.3263076 0.172899171 -0.2967352990 -0.54094916
## [127,] -1.41815751 0.2691834 1.204530888 -0.8152978229 0.47070651
## [128,] -2.14215094 -2.2836023 -1.890364264 -1.7783425101 -1.98617155
## [129,] 0.66332358 -0.2094639 1.946869055 1.0367111910 0.18166203
## [130,] 0.48232523 0.4287325 -0.001768633 0.2959075855 0.61522875
## [131,] 0.48232523 -0.0499148 -0.498480201 0.5922290277 0.18166203
## [132,] 1.38731701 -2.1240532 -0.105477642 0.3699879460 1.19331770
## [133,] 0.66332358 1.3860271 0.074648531 0.6663093882 2.49401786
## [134,] -0.51316573 0.4287325 -0.083644167 -0.0744942173 0.90427323
## [135,] -0.96566162 0.4287325 0.074648531 -0.2967352990 -0.39642692
## [136,] -0.24166820 0.1096343 -0.356562610 0.0736665038 0.18166203
## [137,] 0.12032852 -0.0499148 -0.989733400 0.5181486671 0.18166203
## [138,] -1.78015422 -0.5285621 0.003689735 -1.5561014284 0.61522875
## [139,] -2.32314929 -1.8049550 -3.287706696 -1.7042621495 -2.27521603
## [140,] -0.96566162 -0.8476603 2.307121401 -0.0744942173 -0.39642692
## [141,] -0.33216737 0.2691834 -0.247395233 -0.0744942173 0.47070651
## [142,] -0.78466327 0.2691834 -0.100019273 -0.1485745779 0.32618427
## [143,] 1.11581948 2.9815182 1.204530888 1.1107915516 2.20497338
## [144,] 1.11581948 1.5455762 1.089905142 0.9626308304 1.04879547
## [145,] 0.12032852 0.9073798 0.937070813 0.4440683066 0.90427323
## [146,] -1.05616080 -0.8476603 -1.027941982 -0.3708156595 -0.25190468
## [147,] -0.33216737 0.4287325 0.396692294 -0.2226549384 -0.10738245
## [148,] -0.78466327 -0.6881112 0.800611591 -0.2226549384 0.03713979
## [149,] -1.96115258 -2.1240532 -1.333610639 -1.2597799862 -1.84164931
## [150,] -1.23715916 -1.1667585 1.723075931 -0.2967352990 -0.97451588
## [151,] -0.96566162 -1.8049550 0.347566975 -1.1856996256 -0.54094916
## [152,] 0.12032852 0.4287325 1.237281101 -1.1116192651 0.18166203
## [153,] 0.84432194 0.4287325 -0.345645873 1.2589522727 0.75975099
## [154,] -0.06066984 0.5882816 0.205649384 0.3699879460 0.75975099
## [155,] 0.57282441 0.5882816 0.554984992 0.8144701093 0.18166203
## [156,] 1.56831537 2.0242236 1.297323159 1.7034344360 2.06045114
## [157,] 0.66332358 1.5455762 1.401032167 1.3330326332 1.04879547
## [158,] -0.69416409 -0.3690130 -0.667689636 -0.5189763806 -0.54094916
## [159,] -1.87065340 -0.2094639 0.238399597 -0.8893781834 0.61522875
## [160,] -2.05165176 -1.3263076 -0.673148005 -1.4820210679 -1.11903812
## [161,] -1.59915587 -1.8049550 -1.939489584 -1.1116192651 -1.55260484
## [162,] -2.68514601 -1.4858567 -0.787773752 -1.7042621495 -1.84164931
## [163,] -1.05616080 -1.6454058 1.919577211 -0.8152978229 -1.26356036
## [164,] -1.32765833 -1.1667585 2.945750559 -1.5561014284 -0.97451588
## [165,] -0.24166820 -0.0499148 -0.531230414 0.3699879460 0.03713979
## [166,] 0.66332358 -1.1667585 0.140148957 0.4440683066 -0.39642692
## [167,] 1.38731701 1.0669289 0.522234779 2.0738362388 1.77140666
## [168,] 0.02982934 0.5882816 0.636860525 0.2959075855 0.47070651
## [169,] -0.33216737 -0.0499148 -0.875107654 -0.2967352990 -0.25190468
## [170,] -0.42266655 -0.8476603 -0.443896512 -0.2967352990 -0.54094916
## [171,] -0.60366491 -1.1667585 -0.613105948 -0.0744942173 -1.26356036
## [172,] -1.41815751 -1.4858567 1.521116283 -1.0375389045 -1.26356036
## [173,] -1.68965505 -1.9645041 0.134690588 0.1477468643 -1.26356036
## [174,] 1.20631865 -1.0072094 -1.017025244 0.8144701093 -0.82999364
## [175,] 0.30132687 0.1096343 0.505859672 0.8144701093 0.32618427
## [176,] 1.02532030 0.9073798 1.253656208 0.8885504699 0.75975099
## [177,] 1.11581948 0.5882816 0.342108606 1.2589522727 1.33783994
## [178,] 2.47330715 0.9073798 1.051696559 2.2960773204 1.33783994
## [179,] 0.12032852 0.4287325 0.527693147 0.9626308304 -0.82999364
## ctc40
## [1,] -1.83660553
## [2,] -0.18640871
## [3,] -1.14603404
## [4,] -1.41957210
## [5,] -0.93975943
## [6,] -0.98460174
## [7,] -0.74693752
## [8,] -1.28952941
## [9,] -1.13258134
## [10,] -1.99803783
## [11,] 0.01986589
## [12,] -2.42852396
## [13,] -2.17292282
## [14,] -0.82765367
## [15,] -0.24470371
## [16,] 0.14094012
## [17,] -0.03394487
## [18,] -0.56308407
## [19,] -0.31645139
## [20,] 0.19026665
## [21,] 0.54900509
## [22,] -0.58550522
## [23,] -0.29851447
## [24,] -0.83662213
## [25,] -0.24021948
## [26,] -0.76935867
## [27,] 0.08264512
## [28,] -1.22226595
## [29,] 0.78666931
## [30,] 1.29338735
## [31,] -0.02946064
## [32,] -0.07878718
## [33,] -0.12362948
## [34,] -0.10120833
## [35,] -0.30748293
## [36,] -1.73346823
## [37,] -0.76039021
## [38,] -0.49133638
## [39,] 0.58936317
## [40,] 1.38307196
## [41,] 2.08709615
## [42,] -0.18192448
## [43,] 0.22165626
## [44,] 0.23062473
## [45,] -1.04738097
## [46,] -2.01597475
## [47,] -0.69312676
## [48,] -0.34784101
## [49,] -2.05184860
## [50,] -0.77384291
## [51,] -0.55411561
## [52,] -0.11017679
## [53,] 0.72389008
## [54,] -0.76487444
## [55,] 0.06022397
## [56,] -0.53617869
## [57,] 0.17232973
## [58,] -0.47339946
## [59,] 0.09161358
## [60,] -1.41508787
## [61,] -0.18192448
## [62,] 0.48174163
## [63,] 0.39205702
## [64,] -0.49582061
## [65,] -0.02049218
## [66,] -0.41958870
## [67,] -1.92180591
## [68,] 0.44586779
## [69,] -2.27157589
## [70,] 0.55797355
## [71,] -1.09222327
## [72,] -1.43302479
## [73,] -0.80074829
## [74,] 0.06470820
## [75,] 2.23059153
## [76,] -0.69312676
## [77,] 0.39205702
## [78,] 0.17232973
## [79,] 0.03331858
## [80,] -1.11912865
## [81,] 0.36515164
## [82,] 1.07366006
## [83,] -0.80523252
## [84,] 2.17678076
## [85,] 0.29788818
## [86,] 0.86738546
## [87,] 1.95705347
## [88,] -0.28506178
## [89,] 0.34273049
## [90,] -0.97563328
## [91,] 0.54900509
## [92,] 0.84048007
## [93,] 0.49967856
## [94,] 0.65214239
## [95,] -1.84557399
## [96,] -0.54066292
## [97,] 1.67454695
## [98,] 1.64315733
## [99,] -0.09672410
## [100,] 0.93016468
## [101,] 0.49967856
## [102,] 0.50864702
## [103,] 0.51313125
## [104,] 0.55348932
## [105,] -0.73796906
## [106,] 0.93016468
## [107,] -0.10120833
## [108,] 0.47277317
## [109,] 0.07367666
## [110,] 0.03331858
## [111,] 0.36066741
## [112,] 0.75527969
## [113,] -0.07430295
## [114,] 0.47277317
## [115,] 0.30237241
## [116,] 0.19475088
## [117,] -1.98906937
## [118,] -0.45546254
## [119,] -1.24468711
## [120,] -0.10120833
## [121,] 0.14542435
## [122,] 0.42793087
## [123,] 0.24407742
## [124,] 0.02435012
## [125,] -0.04291333
## [126,] 0.48174163
## [127,] 1.08711275
## [128,] -0.58102099
## [129,] 2.31130768
## [130,] -0.35680947
## [131,] -0.03842910
## [132,] 0.19026665
## [133,] 0.46380471
## [134,] 0.12748742
## [135,] 0.24407742
## [136,] 0.22614050
## [137,] -0.38371485
## [138,] 1.05572314
## [139,] -2.32090243
## [140,] 2.50861382
## [141,] -0.48236792
## [142,] 0.26201434
## [143,] 0.79115354
## [144,] 0.69698470
## [145,] 0.89429084
## [146,] -0.46891523
## [147,] 0.15439281
## [148,] 1.05123891
## [149,] -0.54514715
## [150,] 1.63867310
## [151,] 0.49519433
## [152,] 0.11403473
## [153,] 0.08712935
## [154,] 0.28443549
## [155,] 0.50416279
## [156,] 1.38755619
## [157,] 1.32926120
## [158,] -0.89043290
## [159,] 0.80909046
## [160,] -0.54514715
## [161,] -1.38369825
## [162,] -0.67070560
## [163,] 2.00189577
## [164,] 3.81800912
## [165,] -0.11466102
## [166,] 0.13197166
## [167,] 1.14989198
## [168,] 0.58039470
## [169,] -0.71554791
## [170,] -0.27160909
## [171,] -0.33887255
## [172,] 1.44585119
## [173,] 0.72389008
## [174,] -0.72003214
## [175,] 0.71043739
## [176,] 0.92568045
## [177,] 0.78666931
## [178,] 1.23957659
## [179,] 0.89877507
## attr(,"scaled:center")
## ca20 mg20 ctc20 ca40 mg40 ctc40
## 50.67039 27.31285 132.23240 45.00559 25.74302 127.25698
## attr(,"scaled:scale")
## ca20 mg20 ctc20 ca40 mg40 ctc40
## 11.049824 6.267663 18.320491 13.498854 6.919350 22.300370
autovalor.autovetor<- eigen(R)
var.porc = autovalor.autovetor$values/ sum(autovalor.autovetor$values)*100
var.acum = cumsum(var.porc)
(porc.explic <- round(data.frame(autovalores = autovalor.autovetor$values,var.porc = var.porc,
var.acum = var.acum), 2))
## autovalores var.porc var.acum
## 1 2.78 46.41 46.41
## 2 1.43 23.79 70.20
## 3 1.04 17.27 87.46
## 4 0.45 7.55 95.02
## 5 0.21 3.43 98.45
## 6 0.09 1.55 100.00
res.pca <- dudi.pca(ACP, scannf =FALSE,nf=4)
names(res.pca)
## [1] "tab" "cw" "lw" "eig" "rank" "nf" "c1" "li" "co" "l1"
## [11] "call" "cent" "norm"
class(res.pca)
## [1] "pca" "dudi"
res.pca$co
## Comp1 Comp2 Comp3 Comp4
## ca20 -0.7050957 0.4477202 -0.40898150 -0.2849303
## mg20 -0.6044184 0.3177066 0.65632861 -0.2281672
## ctc20 -0.6027916 -0.7013317 0.04620424 -0.3373448
## ca40 -0.7490467 0.2831557 -0.51216358 0.1548070
## mg40 -0.7781832 0.1937608 0.40213681 0.3741113
## ctc40 -0.6290841 -0.7118836 -0.10408655 0.2147176
summary(res.pca)
## Class: pca dudi
## Call: dudi.pca(df = ACP, scannf = FALSE, nf = 4)
##
## Total inertia: 6
##
## Eigenvalues:
## Ax1 Ax2 Ax3 Ax4 Ax5
## 2.7882 1.4178 1.0350 0.4571 0.2055
##
## Projected inertia (%):
## Ax1 Ax2 Ax3 Ax4 Ax5
## 46.470 23.629 17.250 7.618 3.425
##
## Cumulative projected inertia (%):
## Ax1 Ax1:2 Ax1:3 Ax1:4 Ax1:5
## 46.47 70.10 87.35 94.97 98.39
##
## (Only 5 dimensions (out of 6) are shown)
eig.val <- get_eigenvalue(res.pca)
head(eig.val)
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 2.7882263 46.470438 46.47044
## Dim.2 1.4177558 23.629263 70.09970
## Dim.3 1.0350275 17.250458 87.35016
## Dim.4 0.4570752 7.617920 94.96808
## Dim.5 0.2055249 3.425415 98.39349
## Dim.6 0.0963903 1.606505 100.00000
par(mfrow=c(1,2))
screeplot(res.pca, main = "",las=2)
barplot(eig.val[, 2], names.arg=1:nrow(eig.val),
main = "",
xlab = "Componentes Principais",
ylab = "Porcentagem de variância",
col ="gray80",las=2)
# Add connected line segments to the plot
lines(x = 1:nrow(eig.val), eig.val[, 2],
type="b", pch=19, col = "black")
# Gráfico das variáveis
s.corcircle(res.pca$co)
# Default plot
fviz_pca_var(res.pca)
# Contribuição relativa a cada coluna
head(res.pca$co^2)
## Comp1 Comp2 Comp3 Comp4
## ca20 0.4971600 0.20045341 0.167265865 0.08118526
## mg20 0.3653216 0.10093751 0.430767245 0.05206029
## ctc20 0.3633577 0.49186619 0.002134832 0.11380154
## ca40 0.5610710 0.08017713 0.262311537 0.02396520
## mg40 0.6055692 0.03754324 0.161714014 0.13995930
## ctc40 0.3957469 0.50677829 0.010834010 0.04610363
fviz_pca_var(res.pca, col.var="contrib")+
scale_color_gradient2(low="white", mid="blue",
high="red", midpoint=8) + theme_minimal()
fviz_pca_var(res.pca, col.var="cos2")+
scale_color_gradient2(low="white", mid="blue",
high="red", midpoint=0.5) + theme_minimal()
fviz_pca_biplot(res.pca, geom = "text") +
theme_minimal()
R = cor(suelo[,c(-1,-2,-3,-10,-11)])
print(R)
## ca20 mg20 ctc20 ca40 mg40 ctc40
## ca20 1.0000000 0.32889087 0.1838628 0.7578897 0.4011063 0.11353503
## mg20 0.3288909 1.00000000 0.2241574 0.2158503 0.6574740 0.06437925
## ctc20 0.1838628 0.22415738 1.0000000 0.1791775 0.2519149 0.76707359
## ca40 0.7578897 0.21585029 0.1791775 1.0000000 0.4442049 0.35120389
## mg40 0.4011063 0.65747396 0.2519149 0.4442049 1.0000000 0.36048846
## ctc40 0.1135350 0.06437925 0.7670736 0.3512039 0.3604885 1.00000000
n = nrow(suelo[,c(-1,-2,-3,-10,-11)])
p = ncol(suelo[,c(-1,-2,-3,-10,-11)])
chi2 = -(n-1-(2*p+5)/6)*log(det(R))
ddl = p*(p-1)/2
print(chi2)
## [1] 577.2681
print(ddl)
## [1] 15
print(pchisq(chi2,ddl,lower.tail=F))
## [1] 2.386775e-113
dim(suelo)
## [1] 179 11
# Visualização da classificação por Grupo
quali.sup <- as.factor(suelo[1:179, 11])
head(quali.sup)
## [1] R3 R3 R3 R3 R3 R3
## Levels: R1 R2 R3
#par(mar=c(5,5,5,5))
s.class(res.pca$li, fac = quali.sup, xax = 1, yax = 2)
# Change the colors
s.class(res.pca$li, fac = quali.sup,
col = c("blue","red","green","black"))
res <- scatter(res.pca, clab.row = 0, posieig = "none")
s.class(res.pca$li, fac = quali.sup, col = c("blue","red",
"green","black"),add.plot = TRUE)
res <- scatter(res.pca, clab.row = 0, posieig = "none")
s.class(res.pca$li, fac = quali.sup, col = c("blue","red",
"green","black"),
add.plot = TRUE, cstar = 0, cellipse = 0)
res <- scatter(res.pca, clab.row = 0, posieig = "none")
s.class(res.pca$li, fac = quali.sup, col = c("blue","red",
"green","black"),
add.plot = TRUE, cstar = 0, cellipse = 0, clabel = 0)
fviz_pca_ind(res.pca, habillage = quali.sup, addEllipses =TRUE,
ellipse.level = 0.70,cex.lab=0.1) + theme_minimal()
fviz_pca_biplot(res.pca,
habillage =suelo$region,
addEllipses = TRUE,
col.var = "black", alpha.var ="contrib",
label = "var") +
scale_color_brewer(palette="Dark2")+
theme_minimal()