Learn R Programming

douconca (version 1.2.3)

predict.wrda: Prediction from cca0 and wrda models

Description

Prediction of response and lc scores from environment data using cca0 and wrda models.

Usage

# S3 method for wrda
predict(
  object,
  ...,
  type = c("response", "lc"),
  rank = "full",
  newdata = NULL,
  weights = NULL,
  scaling = "symmetric"
)

Value

a matrix with the predictions. The exact content of the matrix depends on the type of predictions that are being made.

Arguments

object

return value of cca0 or wrda.

...

Other arguments passed to the function (currently ignored).

type

type of prediction, c( "response", "lc") for response (expected abundance) and constrained scores for sites.

rank

rank (number of axes to use). Default "full" for all axes (no rank-reduction).

newdata

Data in which to look for variables with which to predict.

weights

list of weights of species and of sites in newdata when type = "response", else ignored (default NULL yielding equal species and site weights, both summing to 1). Example: weights = list(species = c(100, 1, 1), sites = c(1, 1, 1, 1)), in that order, with traits of three new species in newdata[[1]] and environmental values (and levels of factors) of four new sites in newdata[[2]]. Species weights are scaled to a sum of one.

scaling

numeric (1,2 or 3) or character "sites", "species" or "symmetric". Default: "symmetric". Either site- (1) or species- (2) related scores are scaled by eigenvalues, and the other set of scores have unit weighted mean square or with 3 both are scaled symmetrically to weighted mean squares equal to the square root of eigenvalues. Negative values are treated as the corresponding positive ones by abs(scaling).

Details

Variables that are in the model but not in newdata are set to their weighted means in the training data. Predictions are thus at the (weighted) mean of the quantitative variables not included. Predictions with not-included factors are at the reference level (the first level of the factor).

In a cca0 model with type = "response", many of the predicted values may be negative, indicating expected absences (0) or small expected response values.

Examples

Run this code
data("dune_trait_env")

# rownames are carried forward in results
rownames(dune_trait_env$comm) <- dune_trait_env$comm$Sites
abun <- dune_trait_env$comm[, -1]  # must delete "Sites"

mod <- cca0(formula = abun ~ A1 + Moist + Mag + Use + Manure,
            data = dune_trait_env$envir)

mod # Proportions equal to those Canoco 5.15

scores(mod, which_cor = c("A1", "X_lot"), display = "cor")

set.seed(123)
anova(mod)
anova(mod, by = "axis")

mod2 <- vegan::cca(abun ~ A1 + Moist + Mag + Use + Manure,
                   data = dune_trait_env$envir)
anova(mod2, by = "axis")

dat <- dune_trait_env$envir
dat$Mag <- "SF"
predict(mod, type = "lc", newdata = dat)

Run the code above in your browser using DataLab