Basado en esta información, realice los siguientes análisis.
Base datos biológica. Realice una prueba de agrupación de cluster con los modelos que se aprendieron en el curso. Determine el modelo de cluster más adecuado (Recuerde utilizar la anotación estadÃstica adecuada) Base de datos ambiental Realice un PCA para tratar de estableces agrupaciones en los parámetros fÃsico quÃmicos
Para los datos biológicos utilice la transformación de log x+1 y matriz Bray Curtis Para los datos ambientales utilice la estandarización y la matriz Euclideana.
library(readxl)
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.6-4
library(ade4)
library(ggplot2)
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
evaluacion_1 <- read_xlsx("./bases_datos/evaluacion03.xlsx",
sheet = 1,
col_names = TRUE)
evaluacion_2 <- read_xlsx("./bases_datos/evaluacion03.xlsx",
sheet = 2,
col_names = TRUE)
#transformacion
biol.log<- decostand(evaluacion_1, method = "log")
#Estandarización
biol.amb <- decostand(evaluacion_2, "standardize")
spe.euc<-vegdist(biol.amb,method="euclidean")
head(biol.amb)
#matriz de resemblanza
biol.bray <-vegdist(biol.log)
biol.bray
## 1 2 3 4 5 6 7
## 2 0.3407719
## 3 0.3268806 0.3616022
## 4 0.3673429 0.3260737 0.4156624
## 5 0.3496083 0.4677922 0.4794769 0.3642430
## 6 0.4165940 0.3405374 0.5237599 0.4170061 0.5036506
## 7 0.4952709 0.4491173 0.4971282 0.4862093 0.5936987 0.3587630
## 8 0.4912891 0.4404254 0.5997982 0.4043059 0.5126793 0.3292588 0.4928927
## 9 0.4161695 0.3631993 0.3454790 0.4384913 0.5133196 0.4976808 0.6182896
## 10 0.3236789 0.3982038 0.4409049 0.3592702 0.4445859 0.2597689 0.4188790
## 11 0.3745594 0.3159359 0.3441687 0.4259875 0.4647454 0.3838001 0.4489491
## 12 0.3794663 0.3799018 0.4987020 0.3461127 0.4712335 0.4640641 0.5368181
## 13 0.3389497 0.3269538 0.3341400 0.3341034 0.4193650 0.4350602 0.5309077
## 14 0.3129351 0.3533286 0.3291083 0.3264548 0.4248017 0.3592139 0.4435276
## 15 0.3684968 0.3351635 0.2831006 0.3858758 0.4614379 0.5061107 0.5512977
## 16 0.3612115 0.4024150 0.4638820 0.3511309 0.2926870 0.4576978 0.5516740
## 17 0.3535817 0.4123581 0.5191367 0.5203113 0.4508843 0.3484048 0.4061806
## 18 0.3711810 0.3912395 0.3178768 0.4903014 0.5697425 0.5599244 0.4870633
## 19 0.5240190 0.5617690 0.5727637 0.5065944 0.4142509 0.5160813 0.5128486
## 20 0.4464481 0.4363677 0.4274079 0.4705341 0.5478702 0.5746441 0.6347951
## 21 0.5234124 0.5973324 0.4428308 0.6330179 0.6059415 0.6626534 0.7374153
## 22 0.4775535 0.5375171 0.4121526 0.5745515 0.5885373 0.5970801 0.6739983
## 23 0.3875996 0.3826233 0.4827121 0.3310424 0.4446702 0.4051961 0.5440999
## 24 0.3539649 0.3393310 0.4555756 0.3666477 0.3785327 0.4563309 0.5561496
## 25 0.4257409 0.4132848 0.5356686 0.4593863 0.4593004 0.3872694 0.5120131
## 26 0.4396820 0.3889050 0.4403385 0.4696591 0.5112137 0.4581186 0.4786315
## 27 0.4211175 0.3761413 0.5425801 0.4482959 0.4730353 0.4427193 0.5620437
## 28 0.3519136 0.4064637 0.4868925 0.4315009 0.3894794 0.4636842 0.4591408
## 29 0.5237622 0.4843992 0.5559034 0.5203756 0.4508320 0.4998853 0.5833428
## 8 9 10 11 12 13 14
## 2
## 3
## 4
## 5
## 6
## 7
## 8
## 9 0.5063240
## 10 0.4430051 0.5132390
## 11 0.5070793 0.2884646 0.3940312
## 12 0.3544078 0.5210747 0.3787294 0.4858900
## 13 0.4429438 0.2677462 0.4056798 0.2804411 0.3950756
## 14 0.4890118 0.4233569 0.3575888 0.3193665 0.4710356 0.3263039
## 15 0.5071222 0.1905096 0.4589225 0.2317221 0.4983176 0.2927692 0.3764855
## 16 0.4192310 0.4598482 0.3987626 0.4899861 0.4420882 0.3999608 0.3686849
## 17 0.5448374 0.5116703 0.3094337 0.3987464 0.4240158 0.5005423 0.4485950
## 18 0.5707160 0.3246382 0.4955418 0.3185902 0.4425807 0.3629200 0.4528610
## 19 0.4240237 0.5107168 0.5143954 0.4868709 0.5780272 0.5135506 0.5418532
## 20 0.5855732 0.2954018 0.5337447 0.3377173 0.5178638 0.3222522 0.5022750
## 21 0.7028741 0.5120734 0.6416373 0.4857541 0.6769899 0.4627332 0.5040551
## 22 0.6440816 0.3870931 0.5974565 0.3998889 0.6424402 0.4023196 0.4853058
## 23 0.3341034 0.4802452 0.3601923 0.4724651 0.3530508 0.3767007 0.3667132
## 24 0.4136401 0.4166462 0.4335202 0.3956848 0.3724357 0.3025496 0.3975843
## 25 0.4733255 0.5432430 0.4725173 0.4674523 0.5562692 0.5241259 0.4360489
## 26 0.4817939 0.4992077 0.5060441 0.4973347 0.4977342 0.4784719 0.4201955
## 27 0.4403664 0.4599808 0.5125389 0.5075369 0.4505645 0.4620938 0.4929417
## 28 0.4057949 0.4726161 0.4192820 0.4107427 0.3948033 0.4621842 0.4664549
## 29 0.5206823 0.4528705 0.5264667 0.4508002 0.4866110 0.4370185 0.4683440
## 15 16 17 18 19 20 21
## 2
## 3
## 4
## 5
## 6
## 7
## 8
## 9
## 10
## 11
## 12
## 13
## 14
## 15
## 16 0.4364763
## 17 0.5303782 0.4859708
## 18 0.3659589 0.5394593 0.4200061
## 19 0.4977362 0.4384384 0.5004916 0.4899475
## 20 0.3392917 0.5477006 0.5269330 0.3216114 0.5310713
## 21 0.4032591 0.6438819 0.7150574 0.6132976 0.7216336 0.6798423
## 22 0.3274020 0.5868608 0.6880435 0.4880229 0.6139194 0.4520408 0.4528053
## 23 0.4655912 0.2649915 0.4991896 0.5228608 0.5117017 0.5524469 0.6650235
## 24 0.3472106 0.3417427 0.4964044 0.5062915 0.4532477 0.5045565 0.5463624
## 25 0.4831496 0.4615665 0.5174328 0.6368339 0.5922860 0.6211559 0.6451740
## 26 0.4899732 0.4706130 0.4996334 0.5179880 0.6167109 0.5694488 0.6813580
## 27 0.4581779 0.4082140 0.4848020 0.5384889 0.5894772 0.5278133 0.6704956
## 28 0.4361400 0.3463550 0.4052713 0.4669443 0.4405258 0.5321880 0.6491597
## 29 0.4406397 0.4921833 0.4939072 0.5879719 0.5387910 0.5527238 0.5469418
## 22 23 24 25 26 27 28
## 2
## 3
## 4
## 5
## 6
## 7
## 8
## 9
## 10
## 11
## 12
## 13
## 14
## 15
## 16
## 17
## 18
## 19
## 20
## 21
## 22
## 23 0.6108639
## 24 0.5280185 0.3830880
## 25 0.6330210 0.4884459 0.4475063
## 26 0.6488946 0.4754055 0.4817589 0.3036479
## 27 0.6449767 0.4320613 0.4058474 0.2702633 0.3103802
## 28 0.6459044 0.3744965 0.3522703 0.3313610 0.3332930 0.3048216
## 29 0.6152046 0.4986675 0.4170885 0.3977784 0.3971419 0.3762888 0.3030802
#Construccion de cluster
complete<-hclust(biol.bray, method = "complete")
single <- hclust(biol.bray, method="single")
average <- hclust(biol.bray, method="average")
plot(complete)
plot(single)
plot(average)
library(clustsig)
#Técnicas para seleccionar los mejores cluster, o la significancia del cluster
single.coph <- cophenetic(single)
cor(biol.bray, single.coph)
## [1] 0.6076423
comp.coph <- cophenetic(complete)
cor(biol.bray, comp.coph)
## [1] 0.677293
UPGMA.coph <- cophenetic(average)
cor(biol.bray, UPGMA.coph) #esta correlacion es mas significativa, dio 0.71
## [1] 0.7050669
#simprof
library(clustsig)
simprof.single<-simprof(biol.log,method.cluster="single",method.distance="braycurtis")
## Warning: This version of the Bray-Curtis index does not use standardization.
## Warning: To use the standardized version, use "actual-braycurtis".
## Warning: See the help documentation for more information.
simprof.plot(simprof.single)
## 'dendrogram' with 2 branches and 29 members total, at height 41.42509
simprof.complete<-simprof(biol.log,method.cluster="complete",method.distance="braycurtis")
## Warning: This version of the Bray-Curtis index does not use standardization.
## Warning: To use the standardized version, use "actual-braycurtis".
## Warning: See the help documentation for more information.
simprof.plot(simprof.complete)
## 'dendrogram' with 2 branches and 29 members total, at height 73.74153
simprof.average<-simprof(biol.log,method.cluster="average",method.distance="braycurtis")
## Warning: This version of the Bray-Curtis index does not use standardization.
## Warning: To use the standardized version, use "actual-braycurtis".
## Warning: See the help documentation for more information.
simprof.plot(simprof.average)
## 'dendrogram' with 2 branches and 29 members total, at height 60.08219
#PCA
chart.Correlation(evaluacion_2)
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
cor(evaluacion_2)
## Temp OD PSO Turbidez ST
## Temp 1.0000000 0.36987635 0.477426867 0.59710952 0.472291538
## OD 0.3698763 1.00000000 0.876935486 -0.02670362 0.279444706
## PSO 0.4774269 0.87693549 1.000000000 0.01758893 0.250611849
## Turbidez 0.5971095 -0.02670362 0.017588932 1.00000000 0.364721367
## ST 0.4722915 0.27944471 0.250611849 0.36472137 1.000000000
## Alcalinidad 0.2379359 0.03957957 0.174813291 -0.03403825 -0.222499686
## P-PO43 0.3940663 0.06582558 0.109373110 0.60258594 0.140915421
## Fluoruro -0.2582463 -0.04629216 -0.003435313 0.02862171 0.063538837
## Cloruro 0.4541742 0.17024456 0.307611881 0.25490956 0.276603944
## NO3 0.2667556 0.06225341 -0.045012349 0.21987937 0.109459441
## Sulfato -0.4215487 -0.36471712 -0.308408530 -0.10975231 -0.024933787
## Sodio 0.3658035 0.12217246 0.239472517 0.25943264 0.137699365
## Coliformes totales 0.2214681 0.10201417 0.173182457 -0.08000542 -0.007719962
## Escherichia coli 0.1889079 0.09320107 0.154710638 -0.06656902 -0.046814569
## Alcalinidad P-PO43 Fluoruro Cloruro NO3
## Temp 0.23793592 0.39406634 -0.258246340 0.454174242 0.26675559
## OD 0.03957957 0.06582558 -0.046292161 0.170244559 0.06225341
## PSO 0.17481329 0.10937311 -0.003435313 0.307611881 -0.04501235
## Turbidez -0.03403825 0.60258594 0.028621706 0.254909564 0.21987937
## ST -0.22249969 0.14091542 0.063538837 0.276603944 0.10945944
## Alcalinidad 1.00000000 0.18020477 -0.072809216 0.452927309 0.32638727
## P-PO43 0.18020477 1.00000000 0.180647828 0.375589303 0.20301484
## Fluoruro -0.07280922 0.18064783 1.000000000 0.277129217 -0.26831941
## Cloruro 0.45292731 0.37558930 0.277129217 1.000000000 0.19889667
## NO3 0.32638727 0.20301484 -0.268319415 0.198896668 1.00000000
## Sulfato -0.15990083 0.07129872 0.589130203 0.353770503 -0.34357532
## Sodio 0.49197095 0.46875810 0.506192478 0.825667330 0.14365725
## Coliformes totales 0.07618924 -0.20373471 -0.096648153 0.028787098 -0.17520954
## Escherichia coli 0.07910262 -0.19984302 -0.089893265 0.009008556 -0.18186309
## Sulfato Sodio Coliformes totales Escherichia coli
## Temp -0.42154865 0.36580350 0.221468087 0.188907925
## OD -0.36471712 0.12217246 0.102014171 0.093201072
## PSO -0.30840853 0.23947252 0.173182457 0.154710638
## Turbidez -0.10975231 0.25943264 -0.080005424 -0.066569018
## ST -0.02493379 0.13769937 -0.007719962 -0.046814569
## Alcalinidad -0.15990083 0.49197095 0.076189235 0.079102620
## P-PO43 0.07129872 0.46875810 -0.203734708 -0.199843018
## Fluoruro 0.58913020 0.50619248 -0.096648153 -0.089893265
## Cloruro 0.35377050 0.82566733 0.028787098 0.009008556
## NO3 -0.34357532 0.14365725 -0.175209543 -0.181863085
## Sulfato 1.00000000 0.33879855 -0.168517773 -0.162691894
## Sodio 0.33879855 1.00000000 -0.028877696 -0.021523747
## Coliformes totales -0.16851777 -0.02887770 1.000000000 0.967513826
## Escherichia coli -0.16269189 -0.02152375 0.967513826 1.000000000
estandarización<-rda(evaluacion_2,scale=T) #Scale realiza estandarización variables; utiliza la matriz de correlaciones.
par(mfrow = c(1, 2)) #divide la pantalla para obtener los dos gráficos
biplot(estandarización, scaling = 1, main = "PCA - scaling: 1")
biplot(estandarización, main = "PCA - scaling: 2")
prin_comp <- prcomp(evaluacion_2, scale. = T)
summary(prin_comp)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 1.901 1.6505 1.4337 1.2620 1.2074 0.90521 0.74310
## Proportion of Variance 0.258 0.1946 0.1468 0.1138 0.1041 0.05853 0.03944
## Cumulative Proportion 0.258 0.4526 0.5994 0.7132 0.8173 0.87585 0.91529
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.62885 0.55361 0.44362 0.32980 0.28898 0.25899 0.16684
## Proportion of Variance 0.02825 0.02189 0.01406 0.00777 0.00597 0.00479 0.00199
## Cumulative Proportion 0.94354 0.96543 0.97949 0.98726 0.99322 0.99801 1.00000
biplot(prin_comp, scale = 0)