Load libraries.
Cargar las librerias que necesitas.
library(ggplot2)
library(dplyr)
library(vegan)
Data
Cargar los datos.
species=read.csv("D:/Curriculum/07_ Cursos/Course_Multivariate_Stat_for_Ecological_Data/data/RDA_species.csv", header=T, row.names=NULL, sep=",")
env=read.csv("D:/Curriculum/07_ Cursos/Course_Multivariate_Stat_for_Ecological_Data/data/RDA_environmetal_standart.csv", header=T, row.names=NULL, sep=",")
Remover la columna de sitos.
species_1 <- select(species, -site)
env_1 <- select(env, -site)
Transformar datos. Hellinger es una transformacián recomendada por Legendre & Callagher (2001) en datos de abundancia y con una respuesta lineal.
species.hel <- decostand(species_1, method = "hellinger")
Variation partitioning is a type of analysis that combines simple RDA and partial RDA to divide the variation of a response variable among two, three or four explanatory data sets. Variation partitioning are generally represented by Venn diagram in which the percentage of explained variance by each explanatory data set (or combination of data stets) is reported.
La partición de la variación es un tipo de análisis que combina un RDA simple y un RDA parcial para dividir la variación de una variable de respuesta entre dos, tres o cuatro conjuntos de datos explicativos. La partición de variación generalmente se representa mediante un diagrama de Venn en el que se informa el porcentaje de varianza explicada por cada conjunto de datos explicativos (o combinación de stets de datos).
Construir el modelo y ejecutar un RDA con las matrices (diferentes factores) separadas.
varp <- varpart(species.hel, ~ temperature + oxygen + pH + conductivity,
~ plants + land_use + margin, ~season,
~ shannon, data = env_1)
varp
##
## Partition of variance in RDA
##
## Call: varpart(Y = species.hel, X = ~temperature + oxygen + pH +
## conductivity, ~plants + land_use + margin, ~season, ~shannon, data =
## env_1)
##
## Explanatory tables:
## X1: ~temperature + oxygen + pH + conductivity
## X2: ~plants + land_use + margin
## X3: ~season
## X4: ~shannon
##
## No. of explanatory tables: 4
## Total variation (SS): 34.967
## Variance: 0.61346
## No. of observations: 58
##
## Partition table:
## Df R.square Adj.R.square Testable
## [aeghklno] = X1 4 0.18350 0.12188 TRUE
## [befiklmo] = X2 6 0.57493 0.52492 TRUE
## [cfgjlmno] = X3 1 0.01788 0.00034 TRUE
## [dhijkmno] = X4 1 0.02924 0.01190 TRUE
## [abefghiklmno] = X1+X2 10 0.63213 0.55386 TRUE
## [acefghjklmno] = X1+X3 5 0.19602 0.11871 TRUE
## [adeghijklmno] = X1+X4 5 0.21542 0.13998 TRUE
## [bcefgijklmno] = X2+X3 7 0.59442 0.53764 TRUE
## [bdefhijklmno] = X2+X4 7 0.58871 0.53113 TRUE
## [cdfghijklmno] = X3+X4 2 0.04857 0.01397 TRUE
## [abcefghijklmno] = X1+X2+X3 11 0.64231 0.55678 TRUE
## [abdefghijklmno] = X1+X2+X4 11 0.64492 0.56001 TRUE
## [acdefghijklmno] = X1+X3+X4 6 0.22853 0.13777 TRUE
## [bcdefghijklmno] = X2+X3+X4 8 0.60821 0.54424 TRUE
## [abcdefghijklmno] = All 12 0.65504 0.56305 TRUE
## Individual fractions
## [a] = X1 | X2+X3+X4 4 0.01881 TRUE
## [b] = X2 | X1+X3+X4 6 0.42528 TRUE
## [c] = X3 | X1+X2+X4 1 0.00304 TRUE
## [d] = X4 | X1+X2+X3 1 0.00627 TRUE
## [e] 0 0.10499 FALSE
## [f] 0 -0.00525 FALSE
## [g] 0 0.01008 FALSE
## [h] 0 0.00034 FALSE
## [i] 0 0.01278 FALSE
## [j] 0 -0.00012 FALSE
## [k] 0 -0.00576 FALSE
## [l] 0 -0.00580 FALSE
## [m] 0 -0.00083 FALSE
## [n] 0 -0.00028 FALSE
## [o] 0 -0.00050 FALSE
## [p] = Residuals 0 0.43695 FALSE
## Controlling 2 tables X
## [ae] = X1 | X3+X4 4 0.12380 TRUE
## [ag] = X1 | X2+X4 4 0.02888 TRUE
## [ah] = X1 | X2+X3 4 0.01914 TRUE
## [be] = X2 | X3+X4 6 0.53028 TRUE
## [bf] = X2 | X1+X4 6 0.42003 TRUE
## [bi] = X2 | X1+X3 6 0.43807 TRUE
## [cf] = X3 | X1+X4 1 -0.00222 TRUE
## [cg] = X3 | X2+X4 1 0.01311 TRUE
## [cj] = X3 | X1+X2 1 0.00292 TRUE
## [dh] = X4 | X2+X3 1 0.00661 TRUE
## [di] = X4 | X1+X3 1 0.01905 TRUE
## [dj] = X4 | X1+X2 1 0.00615 TRUE
## Controlling 1 table X
## [aghn] = X1 | X2 4 0.02894 TRUE
## [aehk] = X1 | X3 4 0.11837 TRUE
## [aegl] = X1 | X4 4 0.12808 TRUE
## [bfim] = X2 | X1 6 0.43198 TRUE
## [beik] = X2 | X3 6 0.53730 TRUE
## [befl] = X2 | X4 6 0.51923 TRUE
## [cfjm] = X3 | X1 1 -0.00316 TRUE
## [cgjn] = X3 | X2 1 0.01272 TRUE
## [cfgl] = X3 | X4 1 0.00206 TRUE
## [dijm] = X4 | X1 1 0.01811 TRUE
## [dhjn] = X4 | X2 1 0.00621 TRUE
## [dhik] = X4 | X3 1 0.01363 TRUE
## ---
## Use function 'rda' to test significance of fractions of interest
Legendre (2008) argued that “Negative values of Adj. R2 are interpreted as zeros; they correspond to cases where the explanatory variables explain less variation than random normal variables would.”
Legendre (2008) sugiere que “los valores negativos de Adj. R2 se interpretan como ceros”. Estos valores corresponden a casos donde las variables explicativas explican menos variación que las variables normales aleatorias"
Plot the results. The plot shows the adjusted R2 values associated with each partition or for overlapping partitions.
Graficar los resultados. El gráfico muestra los valores de R2 ajustados asociados con cada partición o para particiones superpuestas.
plot(varp, digits = 2, Xnames = c('Enviromental factors', 'Vegetation',
"Season","Macroinvertebrates"),
bg = c('navy', 'tomato', "lightblue","gold"))
## Show values for all partitions by putting 'cutoff' low enough:
#plot(varp, cutoff = -Inf, cex = 0.7, bg=2:5)
Test the significance of each individual component.
Probar la significancia de cada componente individual.
# significance of partition from Environment (physicochemical variables)
anova(rda(species.hel ~ temperature + oxygen + pH + conductivity +
Condition(plants + land_use + margin) +
Condition(season) + Condition(shannon), data=env_1))
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
##
## Model: rda(formula = species.hel ~ temperature + oxygen + pH + conductivity + Condition(plants + land_use + margin) + Condition(season) + Condition(shannon), data = env_1)
## Df Variance F Pr(>F)
## Model 4 0.028728 1.5272 0.022 *
## Residual 45 0.211618
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Significance of partition from Physical characteristics
anova(rda(species.hel ~ plants + land_use + margin +
Condition(temperature + oxygen + pH + conductivity) +
Condition(season) + Condition(shannon), data=env_1))
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
##
## Model: rda(formula = species.hel ~ plants + land_use + margin + Condition(temperature + oxygen + pH + conductivity) + Condition(season) + Condition(shannon), data = env_1)
## Df Variance F Pr(>F)
## Model 6 0.26165 9.273 0.001 ***
## Residual 45 0.21162
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Significance of partition from Season
anova(rda(species.hel ~ season +
Condition(plants + land_use + margin) +
Condition(temperature + oxygen + pH + conductivity)
+ Condition(shannon), data=env_1))
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
##
## Model: rda(formula = species.hel ~ season + Condition(plants + land_use + margin) + Condition(temperature + oxygen + pH + conductivity) + Condition(shannon), data = env_1)
## Df Variance F Pr(>F)
## Model 1 0.006206 1.3197 0.176
## Residual 45 0.211618
# Significance of partition from Macroinvertebrates
anova(rda(species.hel ~ shannon +
Condition(plants + land_use + margin) +
Condition(temperature + oxygen + pH + conductivity) +
Condition(season), data=env_1))
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
##
## Model: rda(formula = species.hel ~ shannon + Condition(plants + land_use + margin) + Condition(temperature + oxygen + pH + conductivity) + Condition(season), data = env_1)
## Df Variance F Pr(>F)
## Model 1 0.007807 1.6601 0.098 .
## Residual 45 0.211618
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Physicochemical variables and vegetation around urban lakes are all statistically significant in their contributions to Odonata community composition, even though the amount of variation explained by Physicochemistry is small. There was no statistically significant of season in Odonata composition independent of these other measured drivers.
Las variables fisicoquímicas y vegetales son estadísticamente significativas en sus contribuciones a la variabilidad composición de la comunidad Odonata, aún cuando la cantidad de variación explicada por la fisicoquímica es pequeña. No hubo relación, estadísticamente significativa, de la temporada sobre la composición de Odonata.
Total variation: This is often the total sum of squared differences from the mean of each variable.
Es la suma total de las diferencias al cuadrado de la media de cada variable.
R2: The coefficients of determination (R2 values) are estimates of how much variation has been ‘explained’ by a given partition. In RDA, these are simply the squares of the correlation coefficients calculated.
Los coeficientes de determinación (valores R2) son estimaciones de cuánta variación ha sido explicada por una partición determinada. En RDA, estos son simplemente los cuadrados de los coeficientes de correlación calculados
Adjusted R2: Adjusted coefficients of determination (Adj. R2 values) take the number of explanatory variables used in an analysis into account. This “inflation” occurs even if the variables have no “true” explanatory power or are redundant relative to other explanatory variables. These estimates should be preferred relative to the unadjusted estimates.
Los coeficientes de determinación ajustados (Adj. R2) tienen en cuenta el número de variables explicativas utilizadas en un análisis. Esta “inflación” ocurre incluso si las variables no tienen un poder explicativo “verdadero” o son redundantes en relación con otras variables explicativas. Estas estimaciones deben preferirse en relación con las estimaciones no ajustadas.
Significance: P-values associated with the R2 values will be calculated by permutation. The overall model and the individual partitions will be tested for significance. Only if the overall model is significant should the individual partitions be examined.
Los valores p asociados con los valores R2 se calcularán por permutación. Se probaría la importancia del modelo general y las particiones individuales. Solo si el modelo general es significativo deben examinarse las particiones individuales.
The shared partition(s) is not an interaction term (e.g., as in ANOVA-like analyses), cannot be tested, and hence cannot be assigned a significance value. This is simply the variation in the response data that could be explained by both explanatory matrices. That is, the explanatory matrices are redundant in this partition. The larger this fraction is, the more multicollinearity is present in the model.
Las particiones compartidas no se refieren al término de interacción como en los análisis de tipo ANOVA, no se pueden probar y, por lo tanto, no se les puede asignar un valor de significancia. Esta es simplemente la variación en los datos de respuesta que podría explicarse por ambas matrices explicativas. Es decir, las matrices explicativas son redundantes en esta partición. Cuanto más grande es esta fracción, más multicolinealidad está presente en el modelo.
https://wiki.qcbs.ca/r_workshop10
Legendre, P. (2008). Studying beta diversity: ecological variation partitioning by multiple regression and canonical analysis. Journal of plant ecology, 1(1), 3-8.
Legendre, P., & Gallagher, E. D. (2001). Ecologically meaningful transformations for ordination of species data. Oecologia, 129(2), 271-280.
Legendre, P., & Legendre, L. (2012). Numerical ecology. Elsevier.