Learn R Programming

VGAM (version 0.9-3)

calibrate.qrrvglm: Calibration for CQO and CAO models

Description

Performs maximum likelihood calibration for constrained and unconstrained quadratic and additive ordination models (CQO and CAO models are better known as QRR-VGLMs and RR-VGAMs respectively).

Usage

calibrate.qrrvglm(object, newdata = NULL,
        type = c("latvar", "predictors", "response", "vcov", "all3or4"),
        initial.vals = NULL, ...)

Arguments

object
The fitted CQO/CAO model.
newdata
A data frame with new response data (usually new species data). The default is to use the original data used to fit the model; however, the calibration may take a long time to compute because the computations are expensive.
type
What type of result is to be returned. The first are the calibrated latent variables or site scores. This must be computed always. The "predictors" are the linear/quadratic or additive predictors evaluated at the calibrated la
initial.vals
Initial values for the search. For rank-1 models, this should be a vector of length nrow(newdata), and for rank 2 models this should be a two column matrix with the number of rows equalling the number of rows in newdata<
...
Arguments that are fed into calibrate.qrrvglm.control.

Value

  • The argument type determines what is returned. If type = "all3or4" then all the type values are returned in a list, with the following components. Each component has length nrow(newdata).
  • latvarCalibrated latent variables or site scores.
  • predictorslinear/quadratic or additive predictors. For example, for Poisson families, this will be on a log scale, and for binomial families, this will be on a logit scale.
  • responseFitted values of the response, evaluated at the calibrated latent variables or site scores.
  • vcovEstimated variance-covariance matrix of the calibrated latent variables or site scores. Actually, these are stored in an array whose last dimension is nrow(newdata).

Warning

This function is computationally expensive. Setting trace = TRUE to get a running log is a good idea.

Details

Given a fitted regression CQO/CAO model, maximum likelihood calibration is theoretically easy and elegant. However, the method assumes that all species are independent, which is not really true in practice. More details and references are given in Yee (2012).

The function optim is used to search for the maximum likelihood solution. Good initial values are needed, and calibrate.qrrvglm.control allows the user some control over the choice of these.

References

Yee, T. W. (2012) On constrained and unconstrained quadratic ordination. Manuscript in preparation.

ter Braak, C. J. F. 1995. Calibration. In: Data Analysis in Community and Landscape Ecology by Jongman, R. H. G., ter Braak, C. J. F. and van Tongeren, O. F. R. (Eds.) Cambridge University Press, Cambridge.

See Also

calibrate.qrrvglm.control, calibrate, cqo, cao.

Examples

Run this code
hspider[,1:6] <- scale(hspider[, 1:6])  # Standardize the environmental variables
set.seed(123)
p1 <- cqo(cbind(Pardlugu, Pardmont, Pardnigr, Pardpull, Zoraspin) ~
         WaterCon + BareSand + FallTwig +
         CoveMoss + CoveHerb + ReflLux,
         family = poissonff, data = hspider, Rank = 1,
         IToler = TRUE, Crow1positive = TRUE)

siteNos <- 3:4  # Calibrate these sites
cp1 <- calibrate(p1, new = data.frame(depvar(p1)[siteNos, ]), trace = TRUE)

# Graphically compare the actual site scores with their calibrated values
persp(p1, main = "Site scores: solid=actual, dashed=calibrated",
      label = TRUE, col = "blue", las = 1)
# Actual site scores:
abline(v = latvar(p1)[siteNos], lty = 1, col = 1:length(siteNos))
abline(v = cp1, lty = 2, col = 1:length(siteNos))  # Calibrated values

Run the code above in your browser using DataLab