predict.dcca {douconca} | R Documentation |
Prediction for double-constrained correspondence analysis (dc-CA)
Description
Prediction of traits from environment, environment from traits and response from trait and environment data.
With type = "traits"
and newdata = NULL
, predict gives the
fitted mean traits, i.e. the fitted community weighted means.
With type = "env"
and newdata = NULL
, predict gives the
fitted mean environment, i.e. the fitted species niche centroids.
Usage
## S3 method for class 'dcca'
predict(
object,
...,
type = c("env", "traits", "response", "reg_env", "reg_traits"),
rank = "full",
newdata = NULL
)
Arguments
object |
return value of |
... |
Other arguments passed to the function (currently ignored). |
type |
type of prediction, |
rank |
rank or 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.
For |
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 weighted mean (none of the factor effects
are included).
For type = "response"
and non-null newdata, the species weights of
the training are used; the site weights are taken equal. Many of the
predicted values may be negative, indicating expected absences (0) or small
expected response values.
Regression coefficients obtained with type = "reg_env"
or
type = "reg_traits"
are for standardized traits and environmental
variables.
Value
a matrix with the predictions. The exact content of the matrix
depends on the type
of predictions that are being made.
Examples
data("dune_trait_env")
# rownames are carried forward in results
rownames(dune_trait_env$comm) <- dune_trait_env$comm$Sites
mod <- dc_CA(formulaEnv = ~ A1 + Moist + Mag + Use + Condition(Manure),
formulaTraits = ~ SLA + Height + LDMC + Condition(Seedmass) + Lifespan,
response = dune_trait_env$comm[, -1], # must delete "Sites"
dataEnv = dune_trait_env$envir,
dataTraits = dune_trait_env$traits)
# regression coefficients
predict(mod, type = "reg_env")
predict(mod, type = "reg_traits")
# fit the mean traits at each site (20x6),
# that is CWM at each site
pred.traits <- predict(mod, type = "traits")
head(pred.traits)
# fit the mean environment for each species (28x8)
# that is SNC of each species
pred.env <- predict(mod, type = "env")
head(pred.env)
pred.resp <- predict(mod, type = "response")
# pred has negative values and dc_CA cannot have negatives in the response
# so, modify pred.resp,
#whichgives about similar eigenvalues as the original data
pred.resp[pred.resp < 0] <- 0
mod3 <- dc_CA(formulaEnv = mod$formulaEnv,
formulaTraits = mod$formulaTraits,
response = pred.resp,
dataEnv = dune_trait_env$envir,
dataTraits = dune_trait_env$traits)
mod3$eigenvalues / mod$eigenvalues