Workshop 14: R-mode MVA
Murray Logan 06 Aug 2016
Workshop 14: R-mode MVA Murray Logan 06 Aug 2016 > # might want - - PowerPoint PPT Presentation
Workshop 14: R-mode MVA Murray Logan 06 Aug 2016 > # might want to put this in to make the vector arrows and text look nicer.. > geom_text (data=vectors, aes (y=RDA2,x=RDA1,label=Species, + hjust=0.5*(1- sign (RDA2)),vjust=0.5*(1- sign
Murray Logan 06 Aug 2016
> # might want to put this in to make the vector arrows and text look nicer.. > geom_text(data=vectors, aes(y=RDA2,x=RDA1,label=Species, + hjust=0.5*(1-sign(RDA2)),vjust=0.5*(1-sign(RDA1))), color="red", size=4) Error in eval(expr, envir, enclos): could not find function "geom_text"
R-mode
Sp1 Sp2 Sp3 Sp4 Site1 2 5 Site2 13 7 10 5 Site3 9 5 55 93 Site4 10 6 76 81 Site5 2 6
R-mode
Sp1 Sp2 Sp3 Sp4 Site1 2 5 Site2 13 7 10 5 Site3 9 5 55 93 Site4 10 6 76 81 Site5 2 6
> var(Y) Sp1 Sp2 Sp3 Sp4 Sp1 30.70 15.00 96.35 117.70 Sp2 15.00 8.50 56.25 62.50 Sp3 96.35 56.25 1153.80 1477.85 Sp4 117.70 62.50 1477.85 2122.20
R-mode
Sp1 Sp2 Sp3 Sp4 Site1 2 5 Site2 13 7 10 5 Site3 9 5 55 93 Site4 10 6 76 81 Site5 2 6
> cor(Y) Sp1 Sp2 Sp3 Sp4 Sp1 1.0000000 0.9285656 0.5119379 0.4611202 Sp2 0.9285656 1.0000000 0.5679993 0.4653475 Sp3 0.5119379 0.5679993 1.0000000 0.9444347 Sp4 0.4611202 0.4653475 0.9444347 1.0000000
Axis rotation - eigenanalysis
Sp1 Sp2 Sp3 1 18.0 12.0 3.0 2 23.0 10.0 4.0 3 21.0 10.0 6.0 4 18.0 13.0 4.0 5 22.0 6.0 9.0 6 21.0 9.0 7.0 7 22.0 9.0 7.0 8 20.0 11.0 1.0 9 21.0 9.0 5.0 10 17.0 10.0 5.0
Sp1
4 6 8 12 16Sp3
Axes rotation - eigenanalysis
5 10 15 20 −2 2 4 6 8 10 10 20 30 40 50
Sp2 Sp1 Sp3
Axes rotation - eigenanalysis
Sp1 Sp3
Axes rotation - eigenanalysis
Sp1 Sp3
Axes rotation - eigenanalysis
Axis 2
Axes rotation - eigenanalysis
Axis 2 Axis 3
Axes rotation - eigenanalysis
−10 −5 5 10 −10 −5 5 10 −10 −5 5 10
Axis 1 Axis 2 Axis 3
Principle components analysis
. .
Site 1
.
Site 10
.
Site 9
.
Site 2
.
Site 3
.
Site 8
.
Site 4
.
Site 5
.
Site 6
.
Site 7
Principle components analysis
.
Site 1
.
Site 10
.
Site 9
.
Site 2
.
Site 3
.
Site 8
.
Site 4
.
Site 5
.
Site 6
.
Site 7
Sites Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 5 65 5 Site2 25 39 6 23 Site3 6 42 6 31 Site4 40 14 Site5 6 34 18 12 Site6 29 12 22 Site7 21 5 20 Site8 13 6 37 Site9 60 47 4 Site10 72 34
Principle components analysis
> library(vegan) > data.rda <- rda(data[,-1], scale=TRUE) > summary(data.rda, scaling=2) Call: rda(X = data[, -1], scale = TRUE) Partitioning of correlations: Inertia Proportion Total 10 1 Unconstrained 10 1 Eigenvalues, and their contribution to the correlations Importance of components: PC1 PC2 PC3 PC4 PC5 Eigenvalue 3.8220 2.4205 1.6753 1.1701 0.66872 Proportion Explained 0.3822 0.2420 0.1675 0.1170 0.06687 Cumulative Proportion 0.3822 0.6242 0.7918 0.9088 0.97567 PC6 PC7 PC8 PC9 Eigenvalue 0.14643 0.06784 0.0280 0.001045 Proportion Explained 0.01464 0.00678 0.0028 0.000100 Cumulative Proportion 0.99031 0.99710 0.9999 1.000000 Scaling 2 for species and site scores * Species are scaled proportional to eigenvalues * Sites are unscaled: weighted dispersion equal on all dimensions * General scaling constant of scores: 3.08007 Species scores PC1 PC2 PC3 PC4 PC5 PC6 Sp1
0.08911 -0.50512 0.112154 Sp2 0.5000 -0.157276 0.11701 -0.79900 -0.06343 -0.104375 Sp3 0.9007 -0.170843 0.27779 0.16895 -0.01456 0.038032 Sp4
0.04967 0.27670 0.027303 Sp5
0.47970 -0.01385 0.26323 0.128107 Sp6 0.6212 -0.213901 0.31704 0.63259 -0.04035 -0.101082 Sp7
0.231834 0.61283 -0.01782 -0.32040 0.085889 Sp8
0.925419 -0.04869 0.06432 -0.17279 0.006936 Sp9 0.9110 -0.009745 0.12221 -0.14486 0.05298 0.274048 Sp10 0.1964 0.702341 -0.54197 0.08330 0.30368 0.063979 Site scores (weighted sums of species scores) PC1 PC2 PC3 PC4 PC5 PC6 Site1
0.267341 -1.5154 0.3365 Site2
0.1838 0.8579 -0.024947 -0.2562 0.4380 Site3
0.5434 0.9979 -0.028670 -0.5856 0.4768 Site4 0.08351 1.5556 -1.2827 0.242057 0.5852 -1.5801 Site5 0.75662 1.2398 -0.8607 0.079914 0.6381 2.1217 Site6 1.50003 -0.4718 0.3510 -2.396989 -0.1903 -0.3131 Site7 1.86374 -0.6417 0.9511 1.897781 -0.1210 -0.3032 Site8
0.8632 0.5845 0.000059 -1.3634 -0.8814 Site9
0.5521 -0.042154 1.1052 0.5402 Site10 -0.61180 -0.9973 -0.2446 0.005608 1.7033 -0.8354
Principle components analysis
C
p
e n t l
d i n g s
> scores(data.rda, choices=1:4,display="species", + scaling=0) PC1 PC2 PC3 PC4 Sp1
0.08457936 Sp2 0.26258604 -0.103789073 0.09281608 -0.75834235 Sp3 0.47302827 -0.112742127 0.22034809 0.16035284 Sp4
0.04713954 Sp5
0.38050677 -0.01314949 Sp6 0.32625468 -0.141156180 0.25148155 0.60040642 Sp7
0.152990372 0.48610356 -0.01691299 Sp8
0.610697873 -0.03862036 0.06104665 Sp9 0.47844118 -0.006430814 0.09693508 -0.13748918 Sp10 0.10312211 0.463485199 -0.42989602 0.07906481 attr(,"const") [1] 3.08007
Principle components analysis
C
p
e n t l
d i n g s
> scores(data.rda, choices=1:4,display="sites", + scaling=0) PC1 PC2 PC3 PC4 Site1
8.679697e-02 Site2
0.05966779 0.27853408 -8.099421e-03 Site3
0.17642036 0.32398109 -9.308103e-03 Site4 0.02711372 0.50505835 -0.41646556 7.858829e-02 Site5 0.24564899 0.40253243 -0.27942593 2.594538e-02 Site6 0.48701231 -0.15318789 0.11397034 -7.782255e-01 Site7 0.60509708 -0.20834002 0.30879819 6.161486e-01 Site8
0.28025505 0.18975585 1.915695e-05 Site9
0.17925008 -1.368605e-02 Site10 -0.19863101 -0.32379586 -0.07941286 1.820656e-03 attr(,"const") [1] 3.08007
Principle components analysis
S p e c i e s s c
e s
> summary(data.rda, scaling=2)$species PC1 PC2 PC3 PC4 Sp1
0.08911359 Sp2 0.5000107 -0.157276491 0.11701221 -0.79899645 Sp3 0.9007303 -0.170843477 0.27779043 0.16894923 Sp4
0.04966665 Sp5
0.47970072 -0.01385442 Sp6 0.6212472 -0.213900635 0.31704004 0.63259371 Sp7
0.231833546 0.61282545 -0.01781968 Sp8
0.925419372 -0.04868826 0.06431931 Sp9 0.9110374 -0.009744917 0.12220500 -0.14485986 Sp10 0.1963629 0.702341045 -0.54196521 0.08330341 PC5 PC6 Sp1
0.112154283 Sp2
Sp3
0.038032290 Sp4 0.27669707 0.027303319 Sp5 0.26323433 0.128106871 Sp6
Sp7
0.085888650 Sp8
0.006935947 Sp9 0.05297717 0.274047718 Sp10 0.30367672 0.063978952
Principle components analysis
S p e c i e s s c
e s
> summary(data.rda, scaling=1)$species PC1 PC2 PC3 PC4 Sp1
0.26051036 Sp2 0.8087835 -0.31967764 0.2858800 -2.33574773 Sp3 1.4569603 -0.34725367 0.6786876 0.49389803 Sp4
0.14519308 Sp5
1.1719876 -0.04050134 Sp6 1.0048873 -0.43477095 0.7745809 1.84929399 Sp7
0.47122110 1.4972331 -0.05209320 Sp8
1.88099237 -0.1189534 0.18802797 Sp9 1.4736325 -0.01980736 0.2985669 -0.42347634 Sp10 0.3176233 1.42756699 -1.3241099 0.24352519 PC5 PC6 Sp1
0.92683727 Sp2
Sp3
0.31429690 Sp4 1.06999353 0.22563323 Sp5 1.01793280 1.05866864 Sp6
Sp7
0.70977941 Sp8
0.05731831 Sp9 0.20486387 2.26471634 Sp10 1.17432441 0.52871879
Principle components analysis
S i t e s c
e s
> summary(data.rda, scaling=2)$sites PC1 PC2 PC3 PC4 Site1
2.673408e-01 Site2
0.1837810 0.8579046 -2.494679e-02 Site3
0.5433871 0.9978845 -2.866961e-02 Site4 0.08351215 1.5556152 -1.2827432 2.420575e-01 Site5 0.75661614 1.2398282 -0.8606515 7.991361e-02 Site6 1.50003214 -0.4718295 0.3510366 -2.396989e+00 Site7 1.86374152 -0.6417019 0.9511201 1.897781e+00 Site8
0.8632053 0.5844614 5.900474e-05 Site9
0.5521028 -4.215398e-02 Site10 -0.61179747 -0.9973140 -0.2445972 5.607748e-03 PC5 PC6 Site1
0.3364629 Site2
0.4380054 Site3
0.4768201 Site4 0.5851709 -1.5800521 Site5 0.6380907 2.1216597 Site6
Site7
Site8
Site9 1.1052341 0.5401866 Site10 1.7033003 -0.8353532
Principle components analysis
S i t e s c
e s
> summary(data.rda, scaling=1)$sites PC1 PC2 PC3 PC4 Site1
9.145008e-02 Site2
0.09041742 0.3511449 -8.533624e-03 Site3
0.26733811 0.4084394 -9.807103e-03 Site4 0.05162936 0.76533880 -0.5250336 8.280135e-02 Site5 0.46775954 0.60997643 -0.3522692 2.733629e-02 Site6 0.92735841 -0.23213286 0.1436812 -8.199456e-01 Site7 1.15221289 -0.31570749 0.3892985 6.491799e-01 Site8
0.42468374 0.2392231 2.018393e-05 Site9
0.2259786 -1.441974e-02 Site10 -0.37822892 -0.49066318 -0.1001149 1.918260e-03 PC5 PC6 Site1
0.04071454 Site2
0.05300195 Site3
0.05769882 Site4 0.15132341 -0.19119820 Site5 0.16500833 0.25673679 Site6
Site7
Site8
Site9 0.28581018 0.06536664 Site10 0.44046828 -0.10108402
Axes retention
PC1 PC2 PC3 PC4 PC5 3.822030054 2.420488947 1.675308207 1.170140005 0.668723871 PC6 PC7 PC8 PC9 0.146428210 0.067836468 0.027999675 0.001044563
Axes retention
PC1 PC2 PC3 PC4 PC5 3.822030054 2.420488947 1.675308207 1.170140005 0.668723871 PC6 PC7 PC8 PC9 0.146428210 0.067836468 0.027999675 0.001044563
80%
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 38.22 62.43 79.18 90.88 97.57 99.03 99.71 99.99 PC9 100.00
Axes retention
PC1 PC2 PC3 PC4 PC5 3.822030054 2.420488947 1.675308207 1.170140005 0.668723871 PC6 PC7 PC8 PC9 0.146428210 0.067836468 0.027999675 0.001044563
80%
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 38.22 62.43 79.18 90.88 97.57 99.03 99.71 99.99 PC9 100.00
Scree plot
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
data.rda
Inertia 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5
Ordination plot
> plot(data.rda)
−1.0 −0.5 0.0 0.5 1.0 1.5 2.0 −1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 PC1 PC2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10Biplot
−2 −1 1 2 −1.5 −0.5 0.5 1.5
Scaling=1
PC1 PC2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10−1.5 −0.5 0.5 1.5
Scaling=2
PC2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10Environmental correlates
. .
Site 1
.
Site 10
.
Site 9
.
Site 2
.
Site 3
.
Site 8
.
Site 4
.
Site 5
.
Site 6
.
Site 7
Site pH Slope Pressure Altitude Substrate Site1 6 4 101325 2 Quartz Site2 7 9 101352 510 Shale Site3 7 9 101356 546 Shale Site4 7 7 101372 758 Shale Site5 7 6 101384 813 Shale Site6 8 8 101395 856 Quartz Site7 8 101396 854 Quartz Site8 7 12 101370 734 Shale Site9 8 8 101347 360 Quartz Site10 6 2 101345 356 Quartz
Environmental correlates
P C 1
data.rda$CA$u[, 1] 6.5 7.5Environmental correlates
P C 2
data.rda$CA$u[, 2] 6.5 7.5Environmental correlates
P C 1
> library(car) > vif(lm(data.rda$CA$u[,1]~Slope+Altitude+Pressure+ + Substrate+pH, data=enviro)) Slope Altitude Pressure Substrate pH 2.187796 52.754368 45.804821 5.118418 1.976424
Environmental correlates
P C 1
> library(car) > vif(lm(data.rda$CA$u[,1]~Slope+Altitude+Pressure+ + Substrate+pH, data=enviro)) Slope Altitude Pressure Substrate pH 2.187796 52.754368 45.804821 5.118418 1.976424 > vif(lm(data.rda$CA$u[,1]~Slope+Altitude+Substrate+ + pH, data=enviro)) Slope Altitude Substrate pH 2.116732 1.830014 2.636302 1.968157
Environmental correlates
M u l t i v a r i a t e r e g r e s s i
Three responses
> data.lm<-lm(data.rda$CA$u[,1:3]~Slope+Altitude+Substrate+ + pH, data=enviro)
Environmental correlates
> summary(data.lm)[[1]]$coef Estimate
t value (Intercept) 0.180787455 0.8121647657 0.2225995 Slope
Altitude 0.001127743 0.0003074246 3.6683553 SubstrateShale -0.326063277 0.1951991407 -1.6704135 pH
Pr(>|t|) (Intercept) 0.83265462 Slope 0.44811475 Altitude 0.01446816 SubstrateShale 0.15570393 pH 0.59340544
Environmental correlates
> summary(data.lm)[[1]]$coef Estimate
t value (Intercept) 0.180787455 0.8121647657 0.2225995 Slope
Altitude 0.001127743 0.0003074246 3.6683553 SubstrateShale -0.326063277 0.1951991407 -1.6704135 pH
Pr(>|t|) (Intercept) 0.83265462 Slope 0.44811475 Altitude 0.01446816 SubstrateShale 0.15570393 pH 0.59340544 > summary(data.lm)[[2]]$coef Estimate
t value (Intercept)
Slope
Altitude 0.0003381004 0.000194242 1.7406140 SubstrateShale 0.5480944974 0.123333878 4.4439898 pH 0.0589810882 0.083581058 0.7056753 Pr(>|t|) (Intercept) 0.164169419 Slope 0.668099646 Altitude 0.142232378 SubstrateShale 0.006739835 pH 0.511901060
Environmental correlates
> summary(data.lm)[[1]]$coef Estimate
t value (Intercept) 0.180787455 0.8121647657 0.2225995 Slope
Altitude 0.001127743 0.0003074246 3.6683553 SubstrateShale -0.326063277 0.1951991407 -1.6704135 pH
Pr(>|t|) (Intercept) 0.83265462 Slope 0.44811475 Altitude 0.01446816 SubstrateShale 0.15570393 pH 0.59340544 > summary(data.lm)[[2]]$coef Estimate
t value (Intercept)
Slope
Altitude 0.0003381004 0.000194242 1.7406140 SubstrateShale 0.5480944974 0.123333878 4.4439898 pH 0.0589810882 0.083581058 0.7056753 Pr(>|t|) (Intercept) 0.164169419 Slope 0.668099646 Altitude 0.142232378 SubstrateShale 0.006739835 pH 0.511901060 > summary(data.lm)[[3]]$coef Estimate
t value (Intercept)
Slope 0.0225742272 0.0524716316 0.4302177 Altitude 0.0003341175 0.0006223505 0.5368638 SubstrateShale -0.0908322738 0.3951611784 -0.2298613 pH 0.1162957219 0.2677933269 0.4342742 Pr(>|t|) (Intercept) 0.5278434 Slope 0.6849494 Altitude 0.6143806 SubstrateShale 0.8273072 pH 0.6821907
Horseshoe effect
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 S19 S20
Environmental gradient 5 10 15 20 25 30 35 Abundance Sp 1 Sp 2 Sp 3 Sp 4
Horseshoe effect
10 15 20 25 30 35 5 10 15 20 25 Species 2 Species 1
10 15 20 25 30 5 10 15 20 25 Species 2 Species 3
Horseshoe effect
−0.2 0.0 0.2 0.4 −0.2 0.0 0.2 0.4 Comp.1 Comp.2 1 2 3 4 5 6 7 89 10 11 12 13 14 15 16 17 18 19 20 −2 2 4 −2 2 4 sp1 sp2 sp3 sp4
Principle components analysis
.
Site 1
.
Site 10
.
Site 9
.
Site 2
.
Site 3
.
Site 8
.
Site 4
.
Site 5
.
Site 6
.
Site 7
Sites Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 5 65 5 Site2 25 39 6 23 Site3 6 42 6 31 Site4 40 14 Site5 6 34 18 12 Site6 29 12 22 Site7 21 5 20 Site8 13 6 37 Site9 60 47 4 Site10 72 34
Principle components analysis
Sites Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 5 65 5 Site2 25 39 6 23 Site3 6 42 6 31 Site4 40 14 Site5 6 34 18 12 Site6 29 12 22 Site7 21 5 20 Site8 13 6 37 Site9 60 47 4 Site10 72 34 Site pH Slope Pressure Altitude Substrate Site1 6 4 101325 2 Quartz Site2 7 9 101352 510 Shale Site3 7 9 101356 546 Shale Site4 7 7 101372 758 Shale Site5 7 6 101384 813 Shale Site6 8 8 101395 856 Quartz Site7 8 101396 854 Quartz Site8 7 12 101370 734 Shale Site9 8 8 101347 360 Quartz Site10 6 2 101345 356 Quartz
Redundancy analysis
PCA
predictor
than gradients
Redundancy analysis
O u t p u t s u m m a r y
Call: rda(formula = data.sp ~ Slope + Altitude + Substrate + pH, data = enviro, scale = TRUE) Partitioning of correlations: Inertia Proportion Total 10.000 1.0000 Constrained 6.803 0.6803 Unconstrained 3.197 0.3197 Eigenvalues, and their contribution to the correlations Importance of components: RDA1 RDA2 RDA3 RDA4 PC1 Eigenvalue 3.2736 2.3246 0.94753 0.25721 1.6686 Proportion Explained 0.3274 0.2325 0.09475 0.02572 0.1669 Cumulative Proportion 0.3274 0.5598 0.65457 0.68029 0.8471 PC2 PC3 PC4 PC5 Eigenvalue 0.98370 0.42545 0.08546 0.03393 Proportion Explained 0.09837 0.04255 0.00855 0.00339 Cumulative Proportion 0.94552 0.98806 0.99661 1.00000 Accumulated constrained eigenvalues Importance of components: RDA1 RDA2 RDA3 RDA4 Eigenvalue 3.2736 2.3246 0.9475 0.25721 Proportion Explained 0.4812 0.3417 0.1393 0.03781 Cumulative Proportion 0.4812 0.8229 0.9622 1.00000 Scaling 2 for species and site scores * Species are scaled proportional to eigenvalues * Sites are unscaled: weighted dispersion equal on all dimensions * General scaling constant of scores: 3.08007 Species scores RDA1 RDA2 RDA3 RDA4 PC1 PC2 Sp1
0.53068 -0.06866 0.253791 -0.45077 -0.42289 Sp2 0.4496 0.17767 0.70674 0.047286 -0.20609 0.09076 Sp3 0.8605 0.14459 -0.07160 -0.073481 0.01511 -0.39443 Sp4
0.73807 -0.17492 -0.053209 0.09486 0.28160 Sp5
0.06265 -0.02421 -0.300536 0.66564 0.28803 Sp6 0.6378 0.16243 -0.37542 -0.090719 0.25610 -0.50570 Sp7
0.28574 -0.206257 0.58746 -0.17367 Sp8
0.156707 -0.11938 0.04756 Sp9 0.8211 0.01396 0.04385 -0.058407 -0.23106 -0.21288 Sp10 0.1332 -0.53007 -0.36293 0.008524 -0.63767 0.30795 Site scores (weighted sums of species scores) RDA1 RDA2 RDA3 RDA4 PC1 Site Site1
1.6804 -0.57398 3.8613 -1.3523 Site Site2
0.46703 -2.1620 1.0017 Site Site3
0.56036 -1.9250 1.0466 Site Site4 0.03055 -1.3306 -1.05657 2.8638 -1.2801 Site Site5 0.75712 -1.0386 -0.86818 1.9420 -1.2800 Site Site6 1.58269 0.5814 2.55098 0.9117 -0.6183 Site Site7 2.06536 0.6400 -1.36534 -1.2030 0.7683 Site Site8
0.62009 0.1174 0.5119 Site Site9
0.6559 0.08146 -3.1438 0.1980 Site Site10 -0.61188 1.0369 -0.41586 -1.2624 1.0043 PC2 Site Site1
Site Site2
Site Site3
Site Site4 0.9220 Site Site5 0.2638 Site Site6 0.2723 Site Site7
Site Site8
Site Site9 0.5848 Site Site10 1.9287 Site constraints (linear combinations of constraining variables) RDA1 RDA2 RDA3 RDA4 PC1 Site Site1
1.5920 -0.20599 0.7614 -1.3523 Site Site2
0.06891 0.3099 1.0017 Site Site3
0.1650 1.0466 Site Site4 0.1311 -1.0148 -0.39673 0.1773 -1.2801 Site Site5 0.4262 -1.1215 -1.11563 -0.1698 -1.2800 Site Site6 1.3488 0.5330 2.12023 0.1419 -0.6183 Site Site7 1.9135 0.4873 -1.12627 -0.2722 0.7683 Site Site8
1.35583 0.3537 0.5119 Site Site9
0.7367 0.11148 -2.6608 0.1980 Site Site10 0.1414 1.2455 -0.62218 1.1935 1.0043 PC2 Site Site1
Site Site2
Site Site3
Site Site4 0.9220 Site Site5 0.2638 Site Site6 0.2723 Site Site7
Site Site8
Site Site9 0.5848 Site Site10 1.9287 Biplot scores for constraining variables RDA1 RDA2 RDA3 RDA4 PC1 PC2 Slope
0.66815 -0.21310 Altitude 0.7686 -0.6192 0.15152 -0.05368 SubstrateShale -0.2779 -0.9434 -0.05693 0.17170 pH 0.3768 -0.1196 0.18204 -0.90031 Centroids for factor constraints RDA1 RDA2 RDA3 RDA4 PC1 PC2 SubstrateQuartz 0.2706 0.9189 0.05545 -0.1672 SubstrateShale
0.1672
Redundancy analysis
> summary(data.rda, scaling=2)$biplot RDA1 RDA2 RDA3 Slope
0.66814874 Altitude 0.7686367 -0.6191599 0.15151633 SubstrateShale -0.2778501 -0.9434386 -0.05693409 pH 0.3768405 -0.1195525 0.18203818 RDA4 PC1 PC2 Slope
Altitude
SubstrateShale 0.17170182 pH
Redundancy analysis
b i p l
−1.0 −0.5 0.0 0.5 1.0 1.5 2.0 −1.0 −0.5 0.0 0.5 1.0 1.5 RDA2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site Site1 Site Site2 Site Site3 Site Site4 Site Site5 Site Site6 Site Site7 Site Site8 Site Site9 Site Site10Slope Altitude pH 1 SubstrateQuartz SubstrateShale
Redundancy analysis
Permutation ANOVA
Permutation test for rda under reduced model Permutation: free Number of permutations: 999 Model: rda(formula = data.sp ~ Slope + Altitude + Substrate + pH, data = enviro, scale = TRUE) Df Variance F Pr(>F) Model 4 6.8029 2.6598 0.007 ** Residual 5 3.1971
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Permutation ANOVA (Type III SS)
Permutation test for rda under reduced model Marginal effects of terms Permutation: free Number of permutations: 999 Model: rda(formula = data.sp ~ Slope + Altitude + Substrate + pH, data = enviro, scale = TRUE) Df Variance F Pr(>F) Slope 1 1.0065 1.5741 0.159 Altitude 1 2.2199 3.4718 0.002 ** Substrate 1 1.5685 2.4531 0.033 * pH 1 0.4273 0.6683 0.694 Residual 5 3.1971
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Redundancy analysis
Stepwise model selection
Df AIC F Pr(>F) <none> 20.569 Slope 1 21.306 1.5741 0.170 Altitude 1 23.842 3.4718 0.005 ** Substrate 1 22.561 2.4531 0.025 * pH 1 19.823 0.6683 0.645
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correspondence analysis
PCA
species abundances linearly related to enviro gradients
Correspondence analysis
cause associations between sites and species abundances
Species A Species B Species C Species D Species E
Relative Abundance
Site J Site I Site H Site G Site F Site E Site D Site C Site B Site A
Environmental Gradient
Correspondence analysis
cause associations between sites and species abundances
association between sites and species
Correspondence analysis
Correspondence analysis
> data <- decostand(data[,-1],method="total",MARGIN=2) > data Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Site1 1 0 0.0000000 0.28508772 0.02777778 Site2 0 0.0000000 0.10964912 0.21666667 Site3 0 0.0000000 0.02631579 0.23333333 Site4 0 0.0000000 0.00000000 0.00000000 Site5 0 0.1538462 0.00000000 0.00000000 Site6 1 0.3076923 0.00000000 0.00000000 Site7 0 0.5384615 0.00000000 0.00000000 1 Site8 0 0.0000000 0.00000000 0.07222222 Site9 0 0.0000000 0.26315789 0.26111111 Site10 0 0.0000000 0.31578947 0.18888889 Sp7 Sp8 Sp9 Sp10 Site1 0.0000000 0.0000000 0.0000000 0.0000000 Site2 0.2727273 0.1393939 0.0000000 0.0000000 Site3 0.2727273 0.1878788 0.0000000 0.0000000 Site4 0.0000000 0.2424242 0.0000000 0.5384615 Site5 0.0000000 0.2060606 0.3000000 0.4615385 Site6 0.0000000 0.0000000 0.3666667 0.0000000 Site7 0.0000000 0.0000000 0.3333333 0.0000000 Site8 0.2727273 0.2242424 0.0000000 0.0000000 Site9 0.1818182 0.0000000 0.0000000 0.0000000 Site10 0.0000000 0.0000000 0.0000000 0.0000000
Correspondence analysis
T i l e p l
Species Sites Site10 Site9 Site8 Site7 Site6 Site5 Site4 Site3 Site2 Site1 Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10
Correspondence analysis
I t e r a t i v e r e
e i g h t i n g
Minimize χ2 residuals
Species Sites Site6 Site7 Site5 Site4 Site8 Site3 Site2 Site9 Site10 Site1 Sp1 Sp4 Sp5 Sp7 Sp8 Sp10 Sp9 Sp3 Sp6 Sp2 Species Sites Site1 Site6 Site7 Site10 Site9 Site5 Site2 Site3 Site8 Site4 Sp8 Sp10 Sp7 Sp5 Sp9 Sp4 Sp3 Sp6 Sp2 Sp1Correspondence analysis
C A
> data.ca <- cca(data) > summary(data.ca) Call: cca(X = data) Partitioning of mean squared contingency coefficient: Inertia Proportion Total 3.256 1 Unconstrained 3.256 1 Eigenvalues, and their contribution to the mean squared contingency coefficient Importance of components: CA1 CA2 CA3 CA4 CA5 Eigenvalue 0.9463 0.7823 0.6214 0.5784 0.26286 Proportion Explained 0.2906 0.2402 0.1908 0.1776 0.08073 Cumulative Proportion 0.2906 0.5309 0.7217 0.8994 0.98009 CA6 CA7 CA8 Eigenvalue 0.04315 0.01551 0.006164 Proportion Explained 0.01325 0.00476 0.001890 Cumulative Proportion 0.99334 0.99811 1.000000 Scaling 2 for species and site scores * Species are scaled proportional to eigenvalues * Sites are unscaled: weighted dispersion equal on all dimensions Species scores CA1 CA2 CA3 CA4 CA5 CA6 Sp1
1.8842 -0.86530 0.03061 -0.47720 -0.006432 Sp2 1.1313 0.5380 0.52836 1.74914 -0.05360 0.247953 Sp3 1.0302 0.3407 0.16160 -0.32148 0.00978 -0.135905 Sp4
0.2409 0.47543 -0.02254 1.06125 0.022650 Sp5
0.85632 -0.03372 0.35896 -0.014035 Sp6 1.1250 0.5162 0.37542 -1.61102 -0.05869 0.265755 Sp7
0.78276 -0.02684 -0.79494 -0.033065 Sp8
0.02821 -0.55703 0.053469 Sp9 0.9388 0.1688 -0.07722 0.11955 0.07364 -0.513328 Sp10 0.3026 -1.0196 -1.80371 0.08808 0.43783 0.112936 Site scores (weighted averages of species scores) CA1 CA2 CA3 CA4 CA5 CA6 Site1
1.8842 -0.8653 0.03061 -0.47720 -0.006432 Site2
0.8514 -0.03082 -0.51678 -0.066579 Site3
0.7693 -0.02515 -1.10800 -0.053106 Site4 0.1364 -1.3205 -2.2180 0.12014 0.49068 2.189249 Site5 0.4965 -0.6686 -1.3203 0.05068 0.37618 -2.309429 Site6 1.1313 0.5380 0.5284 1.74914 -0.05360 0.247953 Site7 1.1250 0.5162 0.3754 -1.61102 -0.05869 0.265755 Site8
0.5034 -0.01041 -2.11065 0.079747 Site9
1.1190 -0.04803 1.23098 -0.121948 Site10 -1.1131 -0.1123 0.9944 -0.04620 3.03739 0.206699
Correspondence analysis
C A
> data.ca <- cca(data) > summary(data.ca) Call: cca(X = data) Partitioning of mean squared contingency coefficient: Inertia Proportion Total 3.256 1 Unconstrained 3.256 1 Eigenvalues, and their contribution to the mean squared contingency coefficient Importance of components: CA1 CA2 CA3 CA4 CA5 Eigenvalue 0.9463 0.7823 0.6214 0.5784 0.26286 Proportion Explained 0.2906 0.2402 0.1908 0.1776 0.08073 Cumulative Proportion 0.2906 0.5309 0.7217 0.8994 0.98009 CA6 CA7 CA8 Eigenvalue 0.04315 0.01551 0.006164 Proportion Explained 0.01325 0.00476 0.001890 Cumulative Proportion 0.99334 0.99811 1.000000 Scaling 2 for species and site scores * Species are scaled proportional to eigenvalues * Sites are unscaled: weighted dispersion equal on all dimensions Species scores CA1 CA2 CA3 CA4 CA5 CA6 Sp1
1.8842 -0.86530 0.03061 -0.47720 -0.006432 Sp2 1.1313 0.5380 0.52836 1.74914 -0.05360 0.247953 Sp3 1.0302 0.3407 0.16160 -0.32148 0.00978 -0.135905 Sp4
0.2409 0.47543 -0.02254 1.06125 0.022650 Sp5
0.85632 -0.03372 0.35896 -0.014035 Sp6 1.1250 0.5162 0.37542 -1.61102 -0.05869 0.265755 Sp7
0.78276 -0.02684 -0.79494 -0.033065 Sp8
0.02821 -0.55703 0.053469 Sp9 0.9388 0.1688 -0.07722 0.11955 0.07364 -0.513328 Sp10 0.3026 -1.0196 -1.80371 0.08808 0.43783 0.112936 Site scores (weighted averages of species scores) CA1 CA2 CA3 CA4 CA5 CA6 Site1
1.8842 -0.8653 0.03061 -0.47720 -0.006432 Site2
0.8514 -0.03082 -0.51678 -0.066579 Site3
0.7693 -0.02515 -1.10800 -0.053106 Site4 0.1364 -1.3205 -2.2180 0.12014 0.49068 2.189249 Site5 0.4965 -0.6686 -1.3203 0.05068 0.37618 -2.309429 Site6 1.1313 0.5380 0.5284 1.74914 -0.05360 0.247953 Site7 1.1250 0.5162 0.3754 -1.61102 -0.05869 0.265755 Site8
0.5034 -0.01041 -2.11065 0.079747 Site9
1.1190 -0.04803 1.23098 -0.121948 Site10 -1.1131 -0.1123 0.9944 -0.04620 3.03739 0.206699
Inertia - value
Correspondence analysis
C A
> data.ca <- cca(data) > summary(data.ca) Call: cca(X = data) Partitioning of mean squared contingency coefficient: Inertia Proportion Total 3.256 1 Unconstrained 3.256 1 Eigenvalues, and their contribution to the mean squared contingency coefficient Importance of components: CA1 CA2 CA3 CA4 CA5 Eigenvalue 0.9463 0.7823 0.6214 0.5784 0.26286 Proportion Explained 0.2906 0.2402 0.1908 0.1776 0.08073 Cumulative Proportion 0.2906 0.5309 0.7217 0.8994 0.98009 CA6 CA7 CA8 Eigenvalue 0.04315 0.01551 0.006164 Proportion Explained 0.01325 0.00476 0.001890 Cumulative Proportion 0.99334 0.99811 1.000000 Scaling 2 for species and site scores * Species are scaled proportional to eigenvalues * Sites are unscaled: weighted dispersion equal on all dimensions Species scores CA1 CA2 CA3 CA4 CA5 CA6 Sp1
1.8842 -0.86530 0.03061 -0.47720 -0.006432 Sp2 1.1313 0.5380 0.52836 1.74914 -0.05360 0.247953 Sp3 1.0302 0.3407 0.16160 -0.32148 0.00978 -0.135905 Sp4
0.2409 0.47543 -0.02254 1.06125 0.022650 Sp5
0.85632 -0.03372 0.35896 -0.014035 Sp6 1.1250 0.5162 0.37542 -1.61102 -0.05869 0.265755 Sp7
0.78276 -0.02684 -0.79494 -0.033065 Sp8
0.02821 -0.55703 0.053469 Sp9 0.9388 0.1688 -0.07722 0.11955 0.07364 -0.513328 Sp10 0.3026 -1.0196 -1.80371 0.08808 0.43783 0.112936 Site scores (weighted averages of species scores) CA1 CA2 CA3 CA4 CA5 CA6 Site1
1.8842 -0.8653 0.03061 -0.47720 -0.006432 Site2
0.8514 -0.03082 -0.51678 -0.066579 Site3
0.7693 -0.02515 -1.10800 -0.053106 Site4 0.1364 -1.3205 -2.2180 0.12014 0.49068 2.189249 Site5 0.4965 -0.6686 -1.3203 0.05068 0.37618 -2.309429 Site6 1.1313 0.5380 0.5284 1.74914 -0.05360 0.247953 Site7 1.1250 0.5162 0.3754 -1.61102 -0.05869 0.265755 Site8
0.5034 -0.01041 -2.11065 0.079747 Site9
1.1190 -0.04803 1.23098 -0.121948 Site10 -1.1131 -0.1123 0.9944 -0.04620 3.03739 0.206699
Eigenvalues - component of
Axes retention
> data.ca$CA$eig CA1 CA2 CA3 CA4 CA5 0.946305134 0.782293787 0.621442179 0.578436060 0.262857400 CA6 CA7 CA8 0.043153975 0.015510825 0.006164366 > mean(data.ca$CA$eig) [1] 0.4070205 > data.ca$CA$eig>mean(data.ca$CA$eig) CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE
Axes retention
> data.ca$CA$eig CA1 CA2 CA3 CA4 CA5 0.946305134 0.782293787 0.621442179 0.578436060 0.262857400 CA6 CA7 CA8 0.043153975 0.015510825 0.006164366 > data.ca$CA$eig>0.6 CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
Axes retention
> screeplot(data.ca)
CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8
data.ca
Inertia 0.0 0.2 0.4 0.6 0.8
Ordination plots
−2 −1 1 2 −1.0 0.0 1.0 2.0
Scaling=1
CA1 CA2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10−2 −1 1 2 −1.0 0.0 1.0 2.0
Scaling=2
CA1 CA2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10Ordination plots
species abundances
abundance of that species
Ordination plots
abundances across sites
abundance at that site
The arch effect
−2 −1 1 2 −1.0 0.0 1.0 2.0
Scaling=1
CA1 CA2
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10
Environmental correlates
. .
Site 1
.
Site 10
.
Site 9
.
Site 2
.
Site 3
.
Site 8
.
Site 4
.
Site 5
.
Site 6
.
Site 7
Site pH Slope Pressure Altitude Substrate Site1 6.1 4.2 101325 2 Quartz Site2 6.7 9.2 101352 510 Shale Site3 6.8 8.6 101356 546 Shale Site4 7.0 7.4 101372 758 Shale Site5 7.2 5.8 101384 813 Shale Site6 7.5 8.4 101395 856 Quartz Site7 7.5 0.5 101396 854 Quartz Site8 7.0 11.8 101370 734 Shale Site9 8.4 8.2 101347 360 Quartz Site10 6.2 1.5 101345 356 Quartz
Environmental correlates
> envfit(data.ca,env=enviro[,-1]) ***VECTORS CA1 CA2 r2 Pr(>r) pH 0.91731 -0.39818 0.4044 0.244 Slope
0.355 Pressure 0.98437 -0.17609 0.9833 0.001 *** Altitude 0.90763 -0.41978 0.9828 0.001 ***
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Permutation: free Number of permutations: 999 ***FACTORS: Centroids: CA1 CA2 SubstrateQuartz 0.1358 0.6470 SubstrateShale
Goodness of fit: r2 Pr(>r) Substrate 0.3375 0.033 *
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Permutation: free Number of permutations: 999
Environmental correlates
> plot(data.ca) > plot(envfit(data.ca,env=enviro[,-1]))
−2 −1 1 2 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 CA1 CA2 Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9 Site10 pH Slope Pressure Altitude SubstrateQuartz SubstrateShaleEnvironmental correlates
> data.lm <- lm(data.ca$CA$u[,1:3] ~ enviro$Altitude + enviro$Slope+enviro$pH+enviro$Substrate) > summary(data.lm) Response CA1 : Call: lm(formula = CA1 ~ enviro$Altitude + enviro$Slope + enviro$pH + enviro$Substrate) Residuals: Site1 Site2 Site3 Site4 Site5 Site6 0.422144 0.061252 -0.002323 0.112485 0.232025 0.287221 Site7 Site8 Site9 Site10
Coefficients: Estimate Std. Error t value (Intercept)
1.7269003
enviro$Altitude 0.0033945 0.0006537 5.193 enviro$Slope
0.0551127
enviro$pH
0.2812720
enviro$SubstrateShale -0.5363786 0.4150506
Pr(>|t|) (Intercept) 0.40438 enviro$Altitude 0.00349 ** enviro$Slope 0.53461 enviro$pH 0.93500 enviro$SubstrateShale 0.25275
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4042 on 5 degrees of freedom Multiple R-squared: 0.8972, Adjusted R-squared: 0.815 F-statistic: 10.91 on 4 and 5 DF, p-value: 0.01098 Response CA2 : Call: lm(formula = CA2 ~ enviro$Altitude + enviro$Slope + enviro$pH + enviro$Substrate) Residuals: Site1 Site2 Site3 Site4 Site5 Site6 0.870600 0.004159 -0.109777 -0.243666 0.519301 0.252775 Site7 Site8 Site9 Site10 0.257422 -0.170017 -0.318529 -1.062268 Coefficients: Estimate Std. Error t value (Intercept) 4.214e+00 3.014e+00 1.398 enviro$Altitude
1.141e-03
enviro$Slope 3.346e-03 9.619e-02 0.035 enviro$pH
4.909e-01
enviro$SubstrateShale -1.623e+00 7.244e-01
Pr(>|t|) (Intercept) 0.2209 enviro$Altitude 0.9963 enviro$Slope 0.9736 enviro$pH 0.3321 enviro$SubstrateShale 0.0752 .
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.7054 on 5 degrees of freedom Multiple R-squared: 0.7305, Adjusted R-squared: 0.5149 F-statistic: 3.388 on 4 and 5 DF, p-value: 0.1066 Response CA3 : Call: lm(formula = CA3 ~ enviro$Altitude + enviro$Slope + enviro$pH + enviro$Substrate) Residuals: Site1 Site2 Site3 Site4 Site5 Site6 Site7
1.0341 1.0361 -1.7686 -0.6495 -0.3962 0.5326 Site8 Site9 Site10 0.3479 0.1555 0.9860 Coefficients: Estimate Std. Error t value (Intercept)
5.6952905
enviro$Altitude
0.0021558
enviro$Slope 0.1369508 0.1817607 0.753 enviro$pH 0.0172449 0.9276307 0.019 enviro$SubstrateShale -1.2384816 1.3688304
Pr(>|t|) (Intercept) 0.964 enviro$Altitude 0.964 enviro$Slope 0.485 enviro$pH 0.986 enviro$SubstrateShale 0.407 Residual standard error: 1.333 on 5 degrees of freedom Multiple R-squared: 0.2334, Adjusted R-squared:
F-statistic: 0.3805 on 4 and 5 DF, p-value: 0.8148
Worked Examples
> veg <- read.csv('../data/veg.csv', strip.white=TRUE) > head(veg) SITE HABITAT SP1 SP2 SP3 SP4 SP5 SP6 SP7 SP8 1 1 A 4 36 28 24 99 68 2 2 B 92 84 8 84 4 3 3 A 9 52 4 40 96 68 4 4 A 52 52 12 28 96 24 5 5 C 99 36 88 52 8 72 6 6 A 12 20 40 40 88 68 > data <- read.csv('../data/data.csv', strip.white=TRUE) > head(data) Sites Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7 Sp8 Sp9 Sp10 1 Site1 5 65 5 2 Site2 25 39 6 23 3 Site3 6 42 6 31 4 Site4 40 14 5 Site5 6 34 18 12 6 Site6 29 12 22 > enviro <- read.csv('../data/enviro.csv', strip.white=TRUE) > head(enviro) Site pH Slope Pressure Altitude Substrate 1 Site1 6.1 4.2 101325 2 Quartz 2 Site2 6.7 9.2 101352 510 Shale 3 Site3 6.8 8.6 101356 546 Shale 4 Site4 7.0 7.4 101372 758 Shale 5 Site5 7.2 5.8 101384 813 Shale 6 Site6 7.5 8.4 101395 856 Quartz