Learn R Programming

fuzzySim (version 2.0)

fuzzyRangeChange: Range change based on continuous (fuzzy) values

Description

This function quantifies overall range change (expansion, contraction, maintenance and balance) based on either presence-absence data or the continuous predictions of two models.

Usage

fuzzyRangeChange(pred1, pred2, number = TRUE, prop = TRUE, 
na.rm = TRUE, round.digits = 2, measures = c("Gain", "Loss", 
"Stable presence", "Stable absence", "Balance"), plot = TRUE, ...)

Arguments

pred1

numeric vector containing the predictions (between 0 and 1) of the model that will serve as reference.

pred2

numeric vector containing the predictions (between 0 and 1) of the model whose change will be calculated. Must be of the same length and in the same order as pred1.

number

logical value indicating if results should include the fuzzy number of cases. The default is TRUE.

prop

logical value indicating if results should include the proportion of the total number of cases. The default is TRUE.

na.rm

logical value indicating whether NA values should be ignored. The default is TRUE.

round.digits

argument to pass to fuzzyOverlay, indicating the number of decimal places to which to round pred for calculating 'maintenance' or 'stability'. The default is 2.

measures

character vector listing the range change measures to calculate. The default is all available measures.

plot

logical value indicating whether to make a barplot with the results. The default is TRUE.

additional arguments to be passed to the barplot function (if plot = TRUE).

Value

This function returns a data frame with the following values in different rows (among those that are included in measures):

Gain

sum of the predicted values that have increased from pred1 to pred2 (fuzzy equivalent of the number of gained presences)

Loss

sum of the predicted values that have decreased from pred1 to pred2 (fuzzy equivalent of the number of lost presences)

Stable_presence

fuzzy equivalent of the number of predicted presences that have remained as such (when rounded to round.digits) between pred1 and pred2

Stable_absence

fuzzy equivalent of the number of predicted absences that have remained as such (when rounded to round.digits) between pred1 and pred2)

Balance

sum of the change in predicted values from pred1 to pred2 (fuzzy equivalent of the balance of gained and lost presences)

If prop = TRUE (the default), there is an additional column named "Proportion" in which these values are divided by the total number of reference values (i.e., the fuzzy range or non-range size). If plot = TRUE (the default), a barplot is also produced representing the last column of the result data frame.

See Also

fuzSim, modOverlap for other ways to compare models; fuzzyOverlay for row-wise model comparisons

Examples

Run this code
# NOT RUN {
# get an environmental favourability model for a rotifer species:

data(rotif.env)

names(rotif.env)

fav_current <- multGLM(rotif.env, sp.cols = 18, var.cols = 5:17, 
step = TRUE, FDR = TRUE, trim = TRUE, P = FALSE, Fav = TRUE) $
predictions


# imagine you have a model prediction for this species in a future time
# (here we will create one by randomly jittering the current predictions)

fav_imag <- jitter(fav_current, amount = 0.2)
fav_imag[fav_imag < 0] <- 0
fav_imag[fav_imag > 1] <- 1


# calculate range change given by current and imaginary future predictions:

fuzzyRangeChange(fav_current, fav_imag)

fuzzyRangeChange(fav_current, fav_imag, number = FALSE)

fuzzyRangeChange(fav_current, fav_imag, ylim = c(-1, 1), 
ylab = "Proportional change")
# }

Run the code above in your browser using DataLab