| Title: | Calculating Density-Independent Niche Breadth Indices from Abundance Data |
|---|---|
| Description: | Deriving isodar-based niche breadth indices from abundance data of two or more habitats, including several methods based on pairwise isodars, multidimensional isodars, and isodar-adjusted inequality. |
| Authors: | Shahar Dubiner [aut, cre] (ORCID: <https://orcid.org/0000-0003-1771-0087>), Itai Granot [aut], Jonathan Belmaker [aut] |
| Maintainer: | Shahar Dubiner <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.1 |
| Built: | 2026-06-09 05:56:11 UTC |
| Source: | https://github.com/cran/isoniche |
Fits pairwise isodar relationships between all habitat pairs using
lmodel2::lmodel2() (Model II regression). Each output row represents
the relationship:
fit_isodar( data, hab_cols = NULL, n_habitats = ncol(data), flip_intercept = TRUE )fit_isodar( data, hab_cols = NULL, n_habitats = ncol(data), flip_intercept = TRUE )
data |
A data frame of abundance data with one column per habitat. |
hab_cols |
A character vector of length |
n_habitats |
Integer (>= 2). Number of habitat columns to use, starting at column 1. |
flip_intercept |
Logical. If TRUE (default), flip axes when intercept < 0. |
It is crucial to either place the columns with abundance for each habitat as
the FIRST columns, or to explicitly state the habitat columns in hab\_cols.
If the fitted intercept is negative, the relationship is flipped (axes swapped) to provide a biologically interpretable representation (negative intercepts are meaningless in this context) and model refitted.
The sd column is the residual SD from vertical residuals in the reported equation.
A tibble with one row per habitat pair containing:
habitat_x, habitat_y
slope, intercept
sd: residual SD in the reported equation
p_slope, p_intercept
flipped: TRUE if axes were flipped (due to int<0), FALSE otherwise
set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) fit_isodar(isod, n_habitats = 3)set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) fit_isodar(isod, n_habitats = 3)
Reconstructs habitat abundances for each requested total abundance by solving a weighted least-squares system defined by the pairwise isodars:
isodar_adj_niche( isodars, abundances = NULL, weights = NULL, alpha = 0.1, sig_weights = c(sig = 1, nonsig = 0), method = c("gini"), plot = FALSE, max_search = 10000 )isodar_adj_niche( isodars, abundances = NULL, weights = NULL, alpha = 0.1, sig_weights = c(sig = 1, nonsig = 0), method = c("gini"), plot = FALSE, max_search = 10000 )
isodars |
A data frame returned by |
abundances |
Numeric vector of total abundances. If NULL, the minimal total abundance yielding occupancy in all habitats ("baseline") is chosen when possible; otherwise a default exploratory sequence is used |
weights |
Weighting scheme. One of:
|
alpha |
Numeric in (0, 1). Significance threshold used when |
sig_weights |
Numeric vector of length 2 giving weights for significant and non-significant
isodars when |
method |
Character. Currently only |
plot |
Logical. If TRUE, plots adjusted niche breadth versus total abundance |
max_search |
Integer. Maximum total abundance to search when |
The reconstruction is constrained to be nonnegative and to sum to the requested total abundance (active-set heuristic). Niche breadth is then computed from the reconstructed habitat vector; currently defined as:
of isodar-reconstructed abundances at a given N.
To emphasize the intercept component, use baseline abundances provided by abundances = NULL.
To emphasize the slope component, we recommend to set abundances to the highest n in your dataset.
To see how niche breadth changes as a function of n, enter a vector of increasing abundances.
A tibble with one row per total abundance containing:
total_abundance
niche_breadth
one column per habitat with reconstructed abundance
set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) INB <- fit_isodar(isod, n_habitats = 3) isodar_adj_niche(INB, max_search = 100) # automatically checks only baseline abundance isodar_adj_niche(INB, abundances = c(15, 30, 45), max_search = 100) # set specific valuesset.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) INB <- fit_isodar(isod, n_habitats = 3) isodar_adj_niche(INB, max_search = 100) # automatically checks only baseline abundance isodar_adj_niche(INB, abundances = c(15, 30, 45), max_search = 100) # set specific values
Computes vector- and orthogonal isodar-based niche breadth components
from abundance data across all habitats simultaneously, generalizing the
slope (density-dependent) and intercept/baseline (density-independent)
components of isodars to dimensions.
ndim_isoniche(data, n_habitats = ncol(data), scale = TRUE, weights = TRUE)ndim_isoniche(data, n_habitats = ncol(data), scale = TRUE, weights = TRUE)
data |
A data frame of abundance data (one column per habitat). |
n_habitats |
Integer (>=2). Number of habitat columns to use, starting at column 1. |
scale |
Logical. If |
weights |
Logical. If |
Both indices return values between 0 and 1, where 1 indicates a perfect generalist and 0 a specialist. Habitat axes can optionally be weighted by inverse residual variance.
A tibble with vector, orthogonal, and n_habitats.
set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10)set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10)
Computes niche breadth indices from a set of pairwise isodars (slopes and
intercepts) in the format of the output table of fit_isodar().
Two methods are available: a weighted mean of isodar components and a
weighted inverse variance of the isodars' divergence from neutrality.
pairwise_isoniche( data, method = c("inverse_variance", "mean"), weights = NULL, alpha = 0.1, sig_weights = c(sig = 1, nonsig = 0) )pairwise_isoniche( data, method = c("inverse_variance", "mean"), weights = NULL, alpha = 0.1, sig_weights = c(sig = 1, nonsig = 0) )
data |
A data frame returned by |
method |
Character. One of |
weights |
Weighting scheme for pairwise isodars. One of:
|
alpha |
Numeric in (0, 1). Significance threshold used when |
sig_weights |
Numeric vector of length 2 giving weights for significant and non-significant
isodars when |
A one-row tibble with columns intercept, slope, and method.
set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) INB <- fit_isodar(isod, n_habitats = 3) pairwise_isoniche(INB, method = "inverse_variance", weights = "1/var") pairwise_isoniche(INB, method = "inverse_variance", weights = "sig", sig_weights = c(sig = 1, nonsig = 0.25), alpha = 0.1)set.seed(1) isod <- simulate_isodars(1, 2, 5, 1, noise = 2, n = 10) INB <- fit_isodar(isod, n_habitats = 3) pairwise_isoniche(INB, method = "inverse_variance", weights = "1/var") pairwise_isoniche(INB, method = "inverse_variance", weights = "sig", sig_weights = c(sig = 1, nonsig = 0.25), alpha = 0.1)
Simulates abundance data for three habitats across n sites using
sequential linear relationships (isodars) with Gaussian noise:
hab2 is generated from hab1 using slope1 and int1
hab3 is generated from hab2 using slope2 and int2
simulate_isodars( slope1, slope2, int1, int2, noise = 1, n = 30, hab1_max = 100/(slope1^1.2) - int1 )simulate_isodars( slope1, slope2, int1, int2, noise = 1, n = 30, hab1_max = 100/(slope1^1.2) - int1 )
slope1 |
Numeric. Isodar slope for |
slope2 |
Numeric. Isodar slope for |
int1 |
Numeric. Isodar intercept for |
int2 |
Numeric. Isodar intercept for |
noise |
Numeric (>= 0). Standard deviation of Gaussian noise. |
n |
Integer (> 0). Number of simulated sites. |
hab1_max |
Integer. maximum abundance value in habitat 1 (other maxima calculated from hab1_max). Default is derived to generally suit the isodar parameters, but is arbitrary. |
The output includes simple per-site niche metrics (CV and Gini) computed from the three habitat abundances.
A tibble with one row per simulated site containing:
hab1, hab2, hab3: simulated abundances (nonnegative integers)
total_abundance: hab1 + hab2 + hab3
mean_abundance: total_abundance divided by 3
sd: scaled standard deviation of habitat abundances
cv: coefficient of variation (NA if mean_abundance == 0)
gini: Gini coefficient of habitat abundances
set.seed(1) simulate_isodars(1, 2, 5, 1, noise = 2, n = 10)set.seed(1) simulate_isodars(1, 2, 5, 1, noise = 2, n = 10)