compareResponse {enmSdmX} | R Documentation |
Compare two response curves along one or more predictors
Description
This function calculates a suite of metrics reflecting of niche overlap for two response curves. Response curves are predicted responses of a uni- or multivariate model along a single variable. Depending on the user-specified settings the function calculates these values either at each pair of values of pred1
and pred2
or along a smoothed version of pred1
and pred2
.
Usage
compareResponse(
pred1,
pred2,
data,
predictor = names(data),
adjust = FALSE,
gap = Inf,
smooth = FALSE,
smoothN = 1000,
smoothRange = c(0, 1),
graph = FALSE,
...
)
Arguments
pred1 |
Numeric list. Predictions from first model along |
pred2 |
Numeric list. Predictions from second model along |
data |
Data frame or matrix corresponding to |
predictor |
Character list. Name(s) of predictor(s) for which to calculate comparisons. These must appear as column names in |
adjust |
Logical. If |
gap |
Numeric >0. Proportion of range of predictor variable across which to assume a gap exists. Calculation of |
smooth |
Logical. If |
smoothN |
|
smoothRange |
2-element numeric list or |
graph |
Logical. If |
... |
Arguments to pass to functions like |
Value
Either a data frame (if smooth = FALSE
or a list object with the smooth model plus a data frame (if smooth = TRUE
) . The data frame represents metrics comparing response curves of pred1
and pred2
:
-
predictor
Predictor for which comparison was made -
n
Number of values of predictor at which comparison was calculated -
adjust
adjust
argument. -
smooth
smooth
argument. -
meanDiff
Mean difference between predictions ofpred1
andpred2
(higher ==> more different). -
meanAbsDiff
Mean absolute value of difference between predictions ofpred1
andpred2
(higher ==> more different). -
areaAbsDiff
Sum of the area between curves predicted bypred1
andpred2
, standardized by total potential area between the two curves (i.e., the area available between the minimum and maximum prediction along the minimum and maximum values of the predictor) (higher ==> more different). -
d
Schoener's D -
i
Hellinger's I (adjusted to have a range [0, 1]) -
esp
Godsoe's ESP -
cor
Pearson correlation between predictions ofpred1
andpred2
. -
rankCor
Spearman rank correlation between predictions ofpred1
andpred2
.
References
Warren, D.L., Glor, R.E., and Turelli, M. 2008. Environmental niche equivalency versus conservatism: Quantitative approaches to niche evolution. Evolution 62:2868-2883.
Warren, D.L., Glor, R.E., and Turelli, M. 2008. Erratum. Evolution 62:2868-2883.
Godsoe, W. 2014. Inferring the similarity of species distributions using Species Distribution Models. Ecography 37:130-136.
See Also
Examples
set.seed(123)
data <- data.frame(
x1=seq(-1, 1, length.out=100),
x2=seq(-1, 1, length.out=100) + rnorm(100, 0, 0.3)
)
pred1 <- 1 / (1 + exp(-(0.3 + 2 * (data$x1 - 0.2) -0.3 * data$x2)))
pred2 <- 1 / (1 + exp(-(-0 + 0.1 * data$x1 - 4 * data$x1^2 + 0.4 * data$x2)))
compareResponse(pred1, pred2, data, graph=TRUE)
compareResponse(pred1, pred2, data, smooth=TRUE, graph=TRUE)
compareResponse(pred1, pred2, data, adjust=TRUE, graph=TRUE)