Reduced rank regression.
AJ Inzeman, 1975, "Reduced-rank regression for the multivariate linear model", Journal of Multivariate Analysis.
Chris McComb (2020). Reduced Rank Regression (https://github.com/cmccomb/RedRank), GitHub. Retrieved .
An updated has been made tot eh code per Jorrit Montijn's recommendation.
A very useful function, but it unfortunately has a serious bug in the eigenvalue decomposition part, where matrix VV and VVt are calculated (lines 112-115). There are two issues:
1) The function eigs() only returns the largest 6 eigenvalues, so attempting to run the reduced rank regression with a rank larger than 6 will give an error.
2) More importantly, eigs() already returns the eigenvalues in descending order, so the left-right flip and subsequent selection of eigenvectors on lines 114-115 actually means the components are included in reverse order! E.g., when performing reduced rank regression with 4 components, only the components with the 3rd up to 6th largest eigenvalues are used, instead of the 1st up to 4th.
This issue can be easily fixed by replacing lines 113-115 by the following:
[VVt,~] = eigs(sqrtm(gg)*SSYX*inv(SSXX)*SSXY*sqrtm(gg),tt);
It would be good if the author could fix this error.