User Tools

Site Tools


Sidebar

Mean Ellenberg indicator values in vegetation analysis

eiv:summary.aov.iv

Appendix S3 of the paper Zelený & Schaffers (2012) – Function for one-way ANOVA of mean indicator values among groups of samples, with modified permutation test

summary.aov.iv

Description

The function calculates one-way ANOVA of weighted means of species attributes (e.g. Ellenberg indicator values) among groups of samples. Original parametric test of significance is replaced by modified permutation test, accounting for compositional similarity inherited in mean indicator values.

Usage

summary.aov.iv (x, veg, spec.iv, permutations = 999)

Arguments

x Vector (numerical or factor), classifying the samples into groups.
veg Matrix-like object of community data (samples in rows, species in columns). It should be transformed into presence-absence data (e.g. using function decostand (veg, method = ‘pa’) from vegan package) if the species values are not intended to be weighted by species abundances. Plot numbers should be stored as row names, not as first column of the matrix!
spec.iv Data frame, matrix or vector of species indicator values (species in rows, variables in columns). The order of the species in rows must comply with the order of the species in columns of community matrix veg (no warning is returned if this is not true, but the result will be wrong in such case). Species names should be as row names, not as the first column of the matrix.
permutations Number of permutations for assessing the significance of the fit. If set to 0, the significance test is not calculated.

Details

The function summary.aov.iv is derived from the functions aov, calculating the analysis of variance using lm method, and summary.aov, which summarizes the ANOVA results, including P value from the parametric test. In summary.aov.iv, the original parametric test is replaced by modified permutation test, which creates null distribution of F-values using ANOVA of mean of species indicator values randomized among species. The permutation model requires information about the original vegetation matrix used to calculate the weighted mean of species indicator values and also original species indicator values.

Value

Identical to those of summary.aov.

Author(s)

David Zelený (zeleny@sci.muni.cz). Script borrows heavily from functions aov and summary.aov.

See Also

aov, summary.aov

Examples

Note: to run examples, you need to be connected to internet - the files vltava-spe.csv and vltava-spe.eiv.csv are loaded directly. Before running examples, don't forget to define the function summary.aov.iv.

# Read example data first:
vltava.spe <- read.csv ('http://davidzeleny.net/wiki/lib/exe/fetch.php/eiv:data:vltava-spe.csv', row.names = 1) #species data (presence-absence)
vltava.species.eiv <- read.csv ('http://davidzeleny.net/wiki/lib/exe/fetch.php/eiv:data:vltava-spec.eiv.csv', row.names = 1) # species Ellenberg indicator values
# Load required vegan library:
library (vegan)
# Calculate mean EIVs:
vltava.mean.eiv <- apply (vltava.species.eiv, 2, FUN = function (x) colSums(t(vltava.spe)*x, na.rm = T)/rowSums (vltava.spe[,!is.na(x)], na.rm = T))
# Calculate classification (using chord distance and Ward method, five groups):
clus <- hclust (dist (decostand (vltava.spe, 'norm')), method = 'ward')
groups <- cutree (clus, k = 5)
# Calculate ANOVA with parametric test of significance:
summary (aov (as.matrix (vltava.mean.eiv) ~ as.factor (groups)))
# Response Light :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 28.489 7.1222 36.242 < 2.2e-16 ***
#Residuals 92 18.079 0.1965
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Temp :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 1.0047 0.251181 7.1491 4.664e-05 ***
#Residuals 92 3.2324 0.035135
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Cont :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 0.9468 0.236703 5.8581 0.0003031 ***
#Residuals 92 3.7174 0.040406
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Moist :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 46.022 11.5055 91.823 < 2.2e-16 ***
#Residuals 92 11.528 0.1253
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Nutr :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 73.409 18.352 42.982 < 2.2e-16 ***
#Residuals 92 39.281 0.427
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response React :
# Df Sum Sq Mean Sq F value Pr(>F)
#as.factor(groups) 4 52.952 13.2379 31.741 < 2.2e-16 ***
#Residuals 92 38.370 0.4171
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


# Calculate ANOVA with modified test of significance:
summary.aov.iv (x = groups, veg = vltava.spe, spec.iv = vltava.species.eiv, permutations = 999)
# Response Light :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 28.489 7.1222 36.242 0.001 ***
#Residuals 92 18.079 0.1965
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Temp :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 1.0047 0.251181 7.1491 0.148
#Residuals 92 3.2324 0.035135
#
# Response Cont :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 0.9468 0.236703 5.8581 0.511
#Residuals 92 3.7174 0.040406
#
# Response Moist :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 46.022 11.5055 91.823 0.001 ***
#Residuals 92 11.528 0.1253
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response Nutr :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 73.409 18.352 42.982 0.001 ***
#Residuals 92 39.281 0.427
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Response React :
# Df Sum Sq Mean Sq F value Pr(>F)
#x 4 52.952 13.2379 31.741 0.014 *
#Residuals 92 38.370 0.4171
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Definition of the function

summary.aov.iv <- function (x, veg, spec.iv, permutations = 999)
{
x <- as.factor (x)
spec.iv <- as.matrix (spec.iv)
apply.FUN <- function (x)
{
veg.temp <- veg [,!is.na (x)]
x.temp <- x[!is.na (x)]
colSums (t(veg.temp)*x.temp)/rowSums (veg.temp)
}
apply.FUN.sample <- function (x)
{
veg.temp <- veg [,!is.na (x)]
x.temp <- x[!is.na (x)]
colSums (t(veg.temp)*sample (x.temp))/rowSums (veg.temp)
}
mean.iv <- apply (spec.iv, 2, FUN = apply.FUN)
ss <- summary (aov (mean.iv ~ x))
FUN.F <- function (x) x[1,4]
rand.F <- matrix (nrow = permutations, ncol = dim (spec.iv)[2])
for (i in seq (1, permutations))
{
mean.iv.rand <- apply (spec.iv, 2, FUN = apply.FUN.sample)
rand.F[i,] <- unlist (lapply (summary (aov (mean.iv.rand ~ x)), FUN.F))
}
real.F <- unlist (lapply (ss, FUN.F))
permstore <- sweep (rand.F, 2, real.F, '>')
rand.pvals <- (apply(permstore, 2, sum) + 1)/(permutations + 1)
for (j in seq (dim (mean.iv)[2])) ss[[j]][1,5] <- rand.pvals[j]
ss
}
eiv/summary.aov.iv.txt · Last modified: 2018/04/22 21:53 by david