rdecorana: Decorana: R implementation

rdecoranaR Documentation

Decorana: R implementation

Description

Similar to Fortran implementation in vegan, but all in R.

Usage

rdecorana(
  x,
  iweigh = 0,
  iresc = 4,
  ira = 0,
  mk = 26,
  short = 0,
  before = NULL,
  after = NULL
)

## S3 method for class 'rdecorana'
scores(x, display = "sites", choices = 1:4, origin = FALSE, ...)

Arguments

x

rdecorana result object.

iweigh

Downweighting of rare species (0: no).

iresc

Number of rescaling cycles (0: no rescaling).

ira

Type of analyis (0: detrended, 1: orthogonal).

mk

Number of segments in detrending.

short

Shortest gradient to be rescaled.

before, after

Definition of Hill's piecewise transformation.

display

Scores for "sites" or "species".

choices

Axes to returned.

origin

Return centred scores.

...

Other arguments passed to functions.

Details

This function duplicates vegan function decorana, but is written in R. It is slower, and does not have all features and support of tye vegan function, and there is no need to use this function for data analysis. The function serves two purposes. Firstly, as an R functin it is easier to inspect the algorithm than from C or Fortran code. Secondly, it is more hackable, and it is easier to develop new features, change code or replace functionality than in the compiled code. For instance, it would be trivial to add Detrended Constrained Correspondence Analysis, but this would be impossible without extensive changes in Fortran in the vegan function.

The main function rdecorana performs janitorial tasks, and for detrended CA it has basically only two loops. The first loop finds the next correspondence analysis axis for species and sites, and the second loop performs optional (if iresc > 0) nonlinear rescaling of that axis.

Two non-exported functions are used for finding the correspondence analysis axis: transvu runs one step of reciprocal averaging and the step is repeated so many times that the criterion value converges. Function transvu calls detrend that performs Hill's non-linear rescaling on mk segments. See Examples on alternative detrending methods. In all cases detrending against previous axis is done one axis by time starting from first, and then going again down to the first. For axis 4 the order of detrendings is 1, 2, 3, 2, 1. The criterion value is the one that vegan decorana calls ‘Decorana values’: for orthogonal CA is the eigenvalue, but for detrended CA it is a combination of eigenvalues and strength of detrending.

Non-linear rescaling is performed by function stretch that calls two functions: segment to estimate the dispersion of species, and smooth121 to smooth those estimates on segments (that number of segments is selected internally and mk has no influence. The criterion values for community data x with species and site scores v, u are based on x_ij(u_i-v_j)^2 summarized over sites i. Site scores u are weighted averages of species scores v, and therefore species scores should be symmetrically around corresponding site scores and the statistic describes their weighted dispersion. The purpose of rescaling is to make this dispersion 1 all over the axis. The procedure is complicated, and is best inspected from the code (which is commented).

Value

Currently returns a list of elements evals of Decorana values, with rproj and cproj of scaled row and column scores.

Row and column scores and the convergence criterion which for orthogonal CA is the eigenvalue.

Examples

data(spurn)
(mod <- rdecorana(spurn))
if (require(vegan)) {
## compare to decorana
decorana(spurn)
## ordiplot works
ordiplot(mod, display="sites")
}
## Examples on replacing the detrend() function with other
## alternatives. These need to use the same call as detrend() if we
## do not change the call in transvu.
##
## --- Smooth detrending
## detrend <- function(x, aidot, x1, mk)
##      residuals(loess(x ~ x1, weights=aidot))
## If you have this in the natto Namespace, you must use
## environment(detrend) <- environment(qrao) # any natto function
## assignInNamespace("detrend", detrend, "natto")
## ... but if you source() rdecorana.R, just do it!
## --- Quadratic polynomial detrending
## detrend <- function(x, aidot, x1, mk)
##       residuals(lm.wfit(poly(x1, 2), x, w = aidot))
## --- Orthogonal CA
## detrend <- function(x, aidot, x1, mk)
##       residuals(lm(x ~ x1, w = aidot))
## All these could handle all previous axes simultaneosly, but this
## requires editing transvu call.


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