View source: R/compareResponse.r
| compareResponse | R Documentation |
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.
compareResponse( pred1, pred2, data, predictor = names(data), adjust = FALSE, gap = Inf, smooth = FALSE, smoothN = 1000, smoothRange = c(0, 1), graph = FALSE, ... )
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 TRUE then the responses are first smoothed using loess() then compared at |
smoothN |
|
smoothRange |
2-element numeric list or |
graph |
Logical. If |
... |
Arguments to pass to functions like |
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 of pred1 and pred2 (higher ==> more different).
meanAbsDiff Mean absolute value of difference between predictions of pred1 and pred2 (higher ==> more different).
areaAbsDiff Sum of the area between curves predicted by pred1 and pred2, 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 of pred1 and pred2.
rankCor Spearman rank correlation between predictions of pred1 and pred2.
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.
compareNiches
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.