fuzzyOverlay | R Documentation |
Logical and set operations are useful for comparative distribution modelling, to assess consensus or mismatches between the predictions of different models, and to quantify differences between models obtained for different time periods. Fuzzy set theory (Zadeh 1965, Barbosa & Real 2012) allows performing such operations without converting model predictions from continuous to binary, thus avoiding the application of arbitrary thresholds and the distortion or over-simplification of those predictions. The result is a continuous numerical value quantifying the intersection, union, sum, or other operation among model predictions, whether binary or continuous.
fuzzyOverlay(data, overlay.cols = NULL, op = "intersection",
na.rm = FALSE, round.digits = 2)
data |
matrix, data frame, or multilayer SpatRaster containing the model predictions to compare. |
overlay.cols |
vector of the names or index numbers of the columns or layers to compare. The default is all columns or layers in |
op |
character value indicating the operation to perform between the (specified) prediction columns or layers in 'data'. Options are:
If 'data' has only two columns/layers to compare, further options are:
|
na.rm |
logical value indicating if NA values should be ignored. The default is FALSE, so rows/pixels with NA in any of the prediction columns/layers get NA as a result. |
round.digits |
integer value indicating the number of decimal places to be used if op = "maintenance". The default is 2. |
If your predictions are probabilities, "prob_and" (probabilistic 'and') gives the probability of all species in 'data' occurring simultaneously by multiplying all probabilities; and "prob_or" (probabilistic 'or') gives the probability of any of them occurring at each site. These can be quite restrictive, though; probabilistic "and" can give particularly irrealistically small values.
If you have (or convert your probabilities to) favourability predictions, which can be used directly with fuzzy logic (Real et al. 2006; see Fav
function), you can use "fuzzy_and" or "intersection" to get the favourability for all species to co-occur at each site, and "fuzzy_or" or "union" to get favourability for any of them to occur at each site (Barbosa & Real 2012).
This function returns a vector with length equal to the number of rows in 'data', or (if the input is a SpatRaster) a SpatRaster layer of the same dimensions as the input's first layer, containing the row-wise or pixel-wise result of the operation performed.
A. Marcia Barbosa
Barbosa A.M. & Real R. (2012) Applying fuzzy logic to comparative distribution modelling: a case study with two sympatric amphibians. The Scientific World Journal, 2012, Article ID 428206
Real R., Barbosa A.M. & Vargas J.M. (2006) Obtaining environmental favourability functions from logistic regression. Environmental and Ecological Statistics 13: 237-245.
Zadeh, L.A. (1965) Fuzzy sets. Information and Control, 8: 338-353
fuzSim
, modOverlap
and fuzzyRangeChange
for overall (not row-wise or pixel-wise) comparisons among model predictions.
data(rotif.env)
names(rotif.env)
# get model predictions for 3 of the species in rotif.env:
mods <- multGLM(rotif.env, sp.cols = 18:20, var.cols = 5:17, id.col = 1,
step = TRUE, FDR = TRUE, trim = TRUE)
preds <- mods$predictions[ , c("Abrigh_F", "Afissa_F", "Apriod_F")]
# calculate intersection and union among those predictions:
preds$intersect <- fuzzyOverlay(preds, op = "intersection")
preds$union <- fuzzyOverlay(preds, op = "union")
head(preds)
# imagine you have a model prediction for species 'Abrigh' in a future time
# (here we will create one by randomly jittering the current predictions)
preds$Abrigh_imag <- jitter(preds[ , "Abrigh_F"], amount = 0.2)
preds$Abrigh_imag[preds$Abrigh_imag < 0] <- 0
preds$Abrigh_imag[preds$Abrigh_imag > 1] <- 1
# you can calculate row-wise prediction changes from Abrigh to Abrigh_imag:
preds$Abrigh_exp <- fuzzyOverlay(preds, overlay.cols = c("Abrigh_F",
"Abrigh_imag"), op = "expansion")
preds$Abrigh_contr <- fuzzyOverlay(preds, overlay.cols = c("Abrigh_F",
"Abrigh_imag"), op = "contraction")
preds$Abrigh_chg <- fuzzyOverlay(preds, overlay.cols = c("Abrigh_F",
"Abrigh_imag"), op = "change")
preds$Abrigh_maint <- fuzzyOverlay(preds, overlay.cols = c("Abrigh_F",
"Abrigh_imag"), op = "maintenance")
head(preds)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.