residuals {rrr}R Documentation

Reduced-Rank Regression Residuals

Description

residuals calculates the regression residuals for reduced-rank regression and canonical variate analysis.

Usage

residuals(x, y, type = "identity", rank = "full", k = 0, plot = TRUE)

Arguments

x

data frame or matrix of predictor variables

y

data frame or matrix of response variables

type

type of reduced-rank regression model to fit. type = "identity", the default, uses \mathbf{\Gamma} = \mathbf{I} to fit a reduced-rank regression. type = "pca" fits a principal component analysis model as a special case of reduced-rank regression. type = "cva" fits a canonical variate analysis model as a special case of reduced-rank regression. type = "lda" fits a linear discriminant analysis model as a special case of reduced-rank regression.

rank

rank of coefficient matrix.

k

small constant added to diagonal of covariance matrices to make inversion easier.

plot

if FALSE, returns data frame of rank trace coordinates.

Value

scatterplot matrix of residuals if plot = TRUE, the default, or a data frame of residuals if plot = FALSE.

References

Izenman, A.J. (2008) Modern Multivariate Statistical Techniques. Springer.

Examples

data(tobacco)
tobacco_x <- tobacco[,4:9]
tobacco_y <- tobacco[,1:3]
tobacco_rrr <- rrr(tobacco_x, tobacco_y, rank = 1)
residuals(tobacco_x, tobacco_y, rank = 1, plot = FALSE)
residuals(tobacco_x, tobacco_y, rank = 1)

library(dplyr)
data(COMBO17)
galaxy <- as_data_frame(COMBO17)
galaxy <- select(galaxy, -starts_with("e."), -Nr, -UFS:-IFD)
galaxy <- na.omit(galaxy)
galaxy_x <- select(galaxy, -Rmag:-chi2red)
galaxy_y <- select(galaxy, Rmag:chi2red)
residuals(galaxy_x, galaxy_y, type = "cva", rank = 2, k = 0.001)


[Package rrr version 1.0.0 Index]