cresiduals: Extract Conditional Residuals from Multivariate Linear Model...

View source: R/cresiduals.R

cresidualsR Documentation

Extract Conditional Residuals from Multivariate Linear Model Fits

Description

Residuals from full conditionals of a Multivariate Linear Model (mlm) object. The full conditional for each response is a linear model with all other responses used as predictors in addition to the regressors specified in the formula of the mlm object. This is used to diagnose the multivariate normality assumption in plotenvelope.

Usage

cresiduals(object, standardize = TRUE, ...)

Arguments

object

a mlm object, typically the result of calling lm with a matrix response.

standardize

logical defaults to TRUE, to return studentized residuals using rstandard so they are comparable across responses.

...

further arguments passed to residuals.lm or rstandard.

Details

A residuals function for mlm objects, which returns residuals from a full conditional model, that is, a linear model of each response against all responses as well as predictors, which can be used to diagnose the multivariate normality assumption. These can be standardized (standardize=TRUE) to facilitate overlay plots of multiple responses, as in plotenvelope.

Value

A matrix of residuals

Author(s)

David Warton <david.warton@unsw.edu.au>

References

Warton DI (2022) Eco-Stats - Data Analysis in Ecology, from t-tests to multivariate abundances. Springer, ISBN 978-3-030-88442-0

See Also

cpredict, lm, plotenvelope, residuals, rstandard

Examples

data(iris)
# fit a mlm:
iris.mlm=lm(cbind(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width)~Species,data=iris)
# construct full conditional residuals:
cresiduals(iris.mlm)


ecostats documentation built on Aug. 24, 2022, 9:07 a.m.

Related to cresiduals in ecostats...