Learn R Programming

vegan (version 1.6-8)

predict.cca: Prediction Tools for [Constrained] Ordination (CCA, RDA, DCA, CA, PCA)

Description

Function predict can be used to find site and species scores with new data sets.

Usage

## S3 method for class 'cca':
fitted(object, model = c("CCA", "CA"), ...)
## S3 method for class 'cca':
predict(object, newdata, type = c("response", "wa", "sp", "lc"),
    rank = "full", model = c("CCA", "CA"), scaling = FALSE, ...)
## S3 method for class 'cca':
coef(object, ...)
## S3 method for class 'decorana':
predict(object, newdata, type = c("response", "sites", "species"),
    rank = 4, ...)

Arguments

object
A result object from cca, rda, capscale or decorana.
model
Show constrained ("CCA") or unconstrained ("CA") results.
newdata
New data frame to be used in prediction of species and site scores. For type = "wa" and type = "sp" and in predict.decorana this must be the community data, for type = "lc" a data frame of
type
The type of prediction: "response" gives an approximation of the original data matrix, "wa" the site scores as weighted averages of the community data, "lc" the site scores as linear combinations of envi
rank
The rank or the number of axes used in the approximation. The default is to use all axes (full rank) of the "model" or all available four axes in predict.decorana.
scaling
Scaling or predicted scores with the same meaning as in cca, rda and capscale.
...
Other parameters to the functions.

Value

  • The functions return matrices or vectors as is appropriate.

Details

Function fitted gives the approximation of the original data matrix from the ordination result. Function residuals gives the approximation of the original data from the unconstrained ordination. The fitted.cca and residuals.cca function both have the same marginal totals as the original data matrix, and their entries do not add up to the original data. They are defined so that for model mod <- cca(y ~ x), cca(fitted(mod)) is equal to constrained ordination, and cca(residuals(mod)) is equal to unconstrained part of the ordination.

Function predict can find the estimate of the original data matrix (type = "response") with any rank. With rank = "full" it is identical to fitted. In addition, the function can find the species scores or site scores from the community data matrix. The function can be used with new data, and it can be used to add new species or site sccores to existing ordinations. The function returns (weighted) orthornormal scores by default, and you must specify explicit scaling to add those scores to ordination diagrams. With type = "wa" the function finds the site scores from species scores. In that case, the new data can contain new sites, but species must match in the original and new data. With type = "sp" the function finds species scores from site constraints (linear combination scores). In that case the new data can contain new species, but sites must match in the original and new data. With type = "lc" the function finds the linear combination scores for sites from environmental data. In that case the new data frame must contain all constraining and conditioning environmental variables of the model formula. If a completely new data frame is created, extreme care is needed defining variables similarly as in the original model, in particular with (ordered) factors.

Function coef will give the regression coefficients from centred environmental variables (constraints and conditions) to linear combination scores. The coefficients are for unstandardized environmental variables. The coefficients will be NA for aliased effects.

Function predict.decorana is similar to predict.cca. However, type = "species" is not available in detrended correspondence analysis (DCA), because detrending destroys the mutual reciprocal averaging (except for the first axis when rescaling is not used). Detrended CA does not attempt to approximate the original data matrix, so type = "response" has no meaning in detrended analysis (except with rank = 1).

References

Greenacre, M. J. (1984). Theory and applications of correspondence analysis. Academic Press, London.

Gross, J. (2003). Variance inflation factors. R News 3(1), 13--15.

See Also

cca, rda, capscale, decorana, vif, goodness.cca.

Examples

Run this code
data(dune)
data(dune.env)
mod <- cca(dune ~ A1 + Management + Condition(Moisture), data=dune.env)
# Definition of the concepts 'fitted' and 'residuals'
mod
cca(fitted(mod))
cca(residuals(mod))
# Remove rare species (freq==1) from 'cca' and find their scores
# 'passively'.
freq <- specnumber(dune, MARGIN=2)
freq
mod <- cca(dune[, freq>1] ~ A1 + Management + Condition(Moisture), dune.env)
predict(mod, type="sp", newdata=dune[, freq==1], scaling=2)
# New sites
predict(mod, type="lc", new=data.frame(A1 = 3, Management="NM", Moisture="2"), scal=2)

Run the code above in your browser using DataLab