OCN_to_AEM | R Documentation |
Function that computes asymmetric eigenvector maps from an OCN. These can be used as spatial variables to assess spatial gradients in environmental or ecological data.
OCN_to_AEM(OCN, level = "AG", weight = NULL, resistance = "length", moranI = FALSE)
OCN |
A |
level |
Aggregation level at which AEMs are to be calculated. It
must be equal to either |
weight |
Determines how and if weights should be used to compute the AEMs.
Defaults to |
resistance |
Identifies how resisitance (i.e., the variable negatively related to
the link weight) is calculated. Defaults to |
moranI |
Logical. Should Moran's I statistics be computed and random tests be performed via
|
Possible character strings for weight
are:
"gravity"
w(r) = r_{max}/r
"exponential"
w(r) = \exp(-r/r_{max})
"linear"
w(r) = 1 - r/r_{max}
"parabolic"
w(r) = 1 - (r/r_{max})^2
where w
is the weight value for a given link, r
its resistance value and r_{max}
the maximum resistance value across all links.
A list as produced by a call to aem
. If moranI = TRUE
, a krandtest
resulting from
the call to moran.randtest
is appended to the output list.
aem
, moran.randtest
OCN <- aggregate_OCN(landscape_OCN(OCN_20), thrA = 5)
res <- OCN_to_AEM(OCN) # unweighted AEMs
res$values # eigenvectors associates with the AEMs
plot(OCN, res$vectors[,1], drawNodes = TRUE,
colLevels = c(-max(abs(res$vectors[,1])), max(abs(res$vectors[,1])), 100),
colPalette = hcl.colors(100,"Blue-Red 2")) # plot first eigenvector
res_g <- OCN_to_AEM(OCN, weight = "gravity") # weighted AEMs based on gravity model
fn <- function(r) {1 - r^0.5}
res_f <- OCN_to_AEM(OCN, weight = fn) # weighted AEMs based on user-specified weight function
# compute Moran's I and perform permutation test to assess which eigenfunctions should be retained
res_g <- OCN_to_AEM(OCN, weight = "gravity", moranI = TRUE)
selectedAEM <- which(res_g$moranI$pvalue < 0.05)
# selected eigenfunctions are those with significantly positive spatial autocorrelation
# plot selected eigenfunctions
# (these could be e.g. used as spatial covariates in a species distribution model)
par(mfrow=c(3,4))
for (i in selectedAEM){
plot(OCN, res$vectors[,i], drawNodes = TRUE,
colLevels = c(-max(abs(res$vectors[,i])), max(abs(res$vectors[,i])), 100),
colPalette = hcl.colors(100,"Blue-Red 2"))
title(paste0("AEM",i))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.