corybrunson / ordr

manage ordinations and render biplots in a tidyverse workflow
https://corybrunson.github.io/ordr/
GNU General Public License v3.0
22 stars 5 forks source link

Review recoverers for EVD-based methods #60

Open jbgracey6 opened 1 month ago

jbgracey6 commented 1 month ago

Hi @corybrunson. I believe the following methods could stand to be revised so that the recoverer functions better reflect the inner eigenvalue decomposition:

Currently, these functions take as rows the elements that are really supplemental rows, in this case the transposed columns. To remedy this, I think we should define recover_supp_rows.{function}() for each method and have recover_rows.{function}() return a 0xn matrix, as we did for psych::principal() and stats::princomp().

corybrunson commented 1 month ago

@jbgracey6 thanks a lot. I agree, after a glimpse at some source code, that these are the methods to revise.

We will need to check, for each case, (1) how the input data are processed before the eigen-decomposition and (2) how the eigen-decomposition is annotated as output. I think it would be valuable to talk through each case here for future reference.

For example, when the input data d to cmdscale() is a matrix with both row and column names, it is modified only element-wise (e.g. d^2), and then the output $points (which are inertia-laden eigenvectors) adopt the row names rather than the column names. To me, this means that recover_rows() should recover $points while recover_cols() should recover an empty matrix. My guess is that factanal() will behave like princomp(), as you say, but i have not looked closely.

eigen() may be an exception. This is a raw decomposition function; the input matrix x is not modified at all before being passed to one of the La_*() functions, and there is no output annotation derived from some data analytic interpretation. So it might make sense to return the matrix of eigenvectors both as active rows and as active columns. Or, it may just be time to retire the wrapper function eigen_ord(), since eigen() now produces an object of class 'eigen' as output.