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. |
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)