Description Usage Arguments Details Value Author(s) References See Also Examples

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.

1 2 | ```
fuzzyOverlay(data, overlay.cols = 1:ncol(data), op = "intersection",
na.rm = FALSE, round.digits = 2)
``` |

`data` |
matrix or data frame containing the model predictions to compare. |

`overlay.cols` |
vector of the names or index numbers of the columns to compare. The default is all columns in |

`op` |
character value indicating the operation to perform between the prediction columns in 'data'. Can be "consensus" for the arithmetic mean of predictions (or the fuzzy equivalent of the proportion of models that agree that the species occurs at each site), "fuzzy_and" or "intersection" for fuzzy intersection; "fuzzy_or" or "union" for fuzzy union; "prob_and" or "prob_or" for probabilistic and/or, respectively (see Details); "maintenance" for the values where all predictions for the same row (rounded to the number of digits specified in the next argument) are the same. If 'data' has only two columns to compare, you can also calculate"xor" for exclusive 'or', "AnotB"" for the the occurrence of the species in column 1 in detriment of that in column 2, "expansion" for the prediction increase in rows where column 2 has higher values than column 1, "contraction" for the prediction decrease in rows where column 2 has lower values than column 1, or "change" for a mix of the latter two, with positive values where there has been an increase and negative values where there was decrease in favourability from columns 1 to 2. For expansion, contraction and maintenance, rows where the values do not satisfy the condition (i.e. second column larger, smaller, or roughly equal to the first column) get a value of zero. |

`na.rm` |
logical value indicating if NA values should be ignored. The default is FALSE, so rows with NA in any of the prediction columns 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 co-occurring 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`

, containing the row-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) comparisons among model predictions.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ```
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)
``` |

```
[1] "TDWG4" "LEVEL_NAME"
[3] "REGION_NAME" "CONTINENT"
[5] "Area" "Altitude"
[7] "AltitudeRange" "HabitatDiversity"
[9] "HumanPopulation" "Latitude"
[11] "Longitude" "Precipitation"
[13] "PrecipitationSeasonality" "TemperatureAnnualRange"
[15] "Temperature" "TemperatureSeasonality"
[17] "UrbanArea" "Abrigh"
[19] "Afissa" "Apriod"
[21] "Bangul" "Bcalyc"
[23] "Bplica" "Bquadr"
[25] "Burceo" "Cgibba"
[27] "Edilat" "Flongi"
[29] "Kcochl" "Kquadr"
[31] "Ktropi" "Lbulla"
[33] "Lclost" "Lhamat"
[35] "Lluna" "Llunar"
[37] "Lovali" "Lpatel"
[39] "Lquadr" "Mventr"
[41] "Ppatul" "Pquadr"
[43] "Pvulga" "Specti"
[45] "Tpatin" "Tsimil"
[47] "Ttetra"
All 291 observations used for model training;
none reserved for model testing.
=> Building model 1 of 3 (Abrigh)...
13 input predictor variable(s)
10 variable(s) excluded by 'FDR' function
TemperatureSeasonality, UrbanArea, AltitudeRange, Temperature, Longitude, TemperatureAnnualRange, Precipitation, Altitude, Latitude, PrecipitationSeasonality
0 variable(s) excluded by 'step' function
1 variable(s) excluded by 'modelTrim' function
Area
2 variable(s) INCLUDED IN THE FINAL MODEL
HabitatDiversity, HumanPopulation
=> Building model 2 of 3 (Afissa)...
13 input predictor variable(s)
10 variable(s) excluded by 'FDR' function
Altitude, HabitatDiversity, Temperature, Precipitation, Latitude, Area, TemperatureSeasonality, TemperatureAnnualRange, PrecipitationSeasonality, AltitudeRange
0 variable(s) excluded by 'step' function
1 variable(s) excluded by 'modelTrim' function
Longitude
2 variable(s) INCLUDED IN THE FINAL MODEL
HumanPopulation, UrbanArea
=> Building model 3 of 3 (Apriod)...
13 input predictor variable(s)
3 variable(s) excluded by 'FDR' function
HumanPopulation, Altitude, AltitudeRange
5 variable(s) excluded by 'step' function
Precipitation, TemperatureAnnualRange, Temperature, TemperatureSeasonality, UrbanArea
1 variable(s) excluded by 'modelTrim' function
HabitatDiversity
4 variable(s) INCLUDED IN THE FINAL MODEL
Latitude, Area, PrecipitationSeasonality, Longitude
Finished!
It took 0.5 secs.
Abrigh_F Afissa_F Apriod_F intersect union
1 0.5541130 0.4401038 0.64250205 0.44010378 0.6425020
2 0.6838425 0.5692703 0.60228041 0.56927028 0.6838425
3 0.5839825 0.4458142 0.13675334 0.13675334 0.5839825
4 0.2495365 0.3768434 0.09863099 0.09863099 0.3768434
5 0.3580353 0.3765624 0.14653098 0.14653098 0.3765624
6 0.3586544 0.3778011 0.12470828 0.12470828 0.3778011
Abrigh_F Afissa_F Apriod_F intersect union Abrigh_imag Abrigh_exp
1 0.5541130 0.4401038 0.64250205 0.44010378 0.6425020 0.52155191 0.00000000
2 0.6838425 0.5692703 0.60228041 0.56927028 0.6838425 0.60313312 0.00000000
3 0.5839825 0.4458142 0.13675334 0.13675334 0.5839825 0.59741778 0.01343528
4 0.2495365 0.3768434 0.09863099 0.09863099 0.3768434 0.06292856 0.00000000
5 0.3580353 0.3765624 0.14653098 0.14653098 0.3765624 0.37186088 0.01382559
6 0.3586544 0.3778011 0.12470828 0.12470828 0.3778011 0.17427815 0.00000000
Abrigh_contr Abrigh_chg Abrigh_maint
1 -0.03256110 -0.03256110 0
2 -0.08070934 -0.08070934 0
3 0.00000000 0.01343528 0
4 -0.18660791 -0.18660791 0
5 0.00000000 0.01382559 0
6 -0.18437629 -0.18437629 0
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.