# \donttest{
if(require(vegan)) {
# Illustration of the test of the SSEF on the oribatid mite data
# (Borcard et al. 1992, 1994 for details on the dataset):
# Community data (response matrix):
data(mite)
# Hellinger-transformation of the community data (Legendre and Gallagher 2001):
Y <- decostand(mite, method = "hellinger")
# Environmental explanatory dataset:
data(mite.env)
# We only use two numerical explanatory variables:
env <- mite.env[, 1:2]
dim(Y)
dim(env)
# Coordinates of the 70 sites:
data(mite.xy)
coord <- mite.xy
### Building a list of candidate spatial weighting matrices (SWMs) for the
### optimisation of the SWM selection, separately for 'Y' and 'env':
# We create five candidate SWMs: a connectivity matrix based on a Gabriel graphs, on
# a minimum spanning tree (i.e., two contrasted graph-based SWMs), either
# not weighted, or weighted by a linear function decreasing with the distance),
# and a distance-based SWM corresponding to the connectivity and weighting
# criteria of the original PCNM method:
candidates <- listw.candidates(coord, nb = c("gab", "mst", "pcnm"), weights = c("binary",
"flin"))
### Optimisation of the selection of a SWM:
# SWM for 'Y' (based on the best forward-selected subset of MEM variables):
modsel.Y <- listw.select(Y, candidates, method = "FWD", MEM.autocor = "positive",
p.adjust = TRUE)
names(candidates)[modsel.Y$best.id] # Best SWM selected
modsel.Y$candidates$Pvalue[modsel.Y$best.id] # Adjusted p-value of the global model
modsel.Y$candidates$N.var[modsel.Y$best.id] # Nb of forward-selected MEM variables
modsel.Y$candidates$R2Adj.select[modsel.Y$best.id] # Adjusted R2 of the selected MEM var.
# SWM for 'env' (method = "global" for the optimisation, as all MEM variables are required
# to use MSR):
modsel.env <- listw.select(env, candidates, method = "global", MEM.autocor = "positive",
p.adjust = TRUE)
names(candidates)[modsel.env$best.id] # Best SWM selected
modsel.env$candidates$Pvalue[modsel.env$best.id] # Adjusted p-value of the global model
modsel.env$candidates$N.var[modsel.env$best.id] # Nb of forward-selected MEM variables
modsel.env$candidates$R2Adj.select[modsel.env$best.id] # Adjusted R2 of the selected MEM var.
### We perform the variation partitioning:
# Subset of selected MEM variables within the best SWM:
MEM.spe <- modsel.Y$best$MEM.select
VP <- varpart(Y, env, MEM.spe)
plot(VP)
# Test of the shared space-environment fraction (fraction [b]):
SSEF.test <- envspace.test(Y, env, coord, MEM.spe,
listw.env = candidates[[modsel.env$best.id]],
regular = FALSE, nperm = 999)
SSEF.test
# The SSEF is highly significant, indicating a potential induced spatial dependence.
}
# }
Run the code above in your browser using DataLab