Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

X.residuals

Residuals from the regression of each column of a data.frame against all the other columns.


Description

Calculate the residuals from the regression of each column of a data.frame against all the other columns.

Usage

X.residuals(x, ...)

## Default S3 method:
X.residuals(x, y.name, na.action = na.exclude, ...) ## x is a data.frame

## S3 method for class 'formula'
X.residuals(x, data, na.action = na.exclude, ...)   ## x is a formula

## S3 method for class 'lm'
X.residuals(x, na.action = na.exclude, ...)  ## x is a "lm" object computed with x=TRUE

Arguments

x

data.frame, or formula, or lm object computed with x=TRUE.

na.action

See na.action.

...

additional arguments.

y.name

Name of Y-variable to be excluded from the computations.

data

A data frame in which the variables specified in the formula will be found. If missing, the variables are searched for in the standard way.

Value

Data.frame of residuals, one column from each regression.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

References

Heiberger, Richard M. and Holland, Burt (2015). Statistical Analysis and Data Display: An Intermediate Course with Examples in R. Second Edition. Springer-Verlag, New York. https://www.springer.com/us/book/9781493921218

See Also

Examples

data(usair)
usair$lnSO2 <- log(usair$SO2)
usair$lnmfg <- log(usair$mfgfirms)
usair$lnpopn <- log(usair$popn)

usair.lm <- lm(lnSO2 ~ temp + lnmfg + wind + precip, data=usair)

X.residuals(usair.lm)

X.residuals(lnSO2 ~ temp + lnmfg + wind + precip, data=usair)

X.residuals(usair)

X.residuals(usair, y.name="lnSO2")

HH

Statistical Analysis and Data Display: Heiberger and Holland

v3.1-43
GPL (>= 2)
Authors
Richard M. Heiberger
Initial release
2020-11-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.