distconstrain: Constrained and Residual Dissimilarities

distconstrainR Documentation

Constrained and Residual Dissimilarities

Description

Function constrains dissimilarities by external variables, or alternatively removes effects of constraining variables and returns residual dissimilarities. The analysis is based on McArdle & Anderson (2001), and the analysis of constrained dissimilarities is equal to distance-based Redundancy Analysis (dbrda).

Usage

distconstrain(formula, data, add = FALSE, residuals = FALSE, squared = FALSE)

Arguments

formula

The left-hand-side must be dissimilarities and the right-hand-side should list the constraining variables.

data

Data frame containing the constrainging variables in the formula.

add

an additive constant is added to the non-diagonal dissimilarities such that all n-1 eigenvalues are non-negative. Alternatives are "lingoes" (default, also used with TRUE) and "cailliez" (which is the only alternative in cmdscale).

residuals

Return residuals after constraints.

squared

Return squared dissimilarities instead of dissimilarities. This allows handling negative squared distances by the user instead of setting them NaN.

Details

Function uses the method of McArdle & Anderson (2001) to constrain dissimilarities by external variables, or alternatively, to find residual dissimilarities after constraints. With Euclidean distances, the method is equal to performing linear regressions on each column in the raw data and then calculationg the distances, but works directly on distances. With other methods, there is no similar direct connection to the raw data, but it is possible to work with non-Euclidean metrics. The same basic method is used within db-RDA (dbrda in vegan), but this function exposes the internal calculations to users.

Non-Euclidean indices can produce negative eigenvalues in db-RDA. Would negative eigenvalues be produced, this function can return negative squared distances resulting in NaN when taking the square root. Db-RDA works with the internal presentation of the dissimilarities, and its analysis does not suffer from the imaginary distances, but these can ruin the analysis of dissimilarities returned from this function.

References

McArdle, B.H. & Anderson, M.J. (2001). Fitting multivariate models to community data: a comment on distance-based redundancy analysis. Ecology 82, 290–297.


jarioksa/natto documentation built on March 28, 2024, 12:45 a.m.