-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SparseM based approach to issue 134 #136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this nice new implementation, slm_fit_csr()
returns a Cholesky decomp (chol
) and coefficients
corresponding to the gramian_reduction_indices
(set equal to which(!zeroes)
, with zeroes
as in the body of SparseM_solve()
.
Relatedly, I'll suggest renaming create_SparseM_reduction_matrix()
to gramian_reduction()
or SparseM_gramian_reduction()
.
I appreciate the testing of create_SparseM_reduction_matrix()
, and the code factoring that allowed it to happen. Thanks!
Including the index as part of the returned information is a good idea. I've added it as another element to the named list that gets returned from One thing to note -- As currently implemented, this index gets returned even when there are no zeroes on the diagonal. I can see an argument for only including it when necessary -- that is, when the reduction process is actually needed -- but my instinct would be to keep it there for consistency, even if slightly redundant. |
No, thank you! All this looks good to me now. I'll invite Jake to take a quick look, and if he's OK too then this can go into master. Regarding Adam's "one thing to note," I think that in cases where no reduction of the Gramian was necessary, it's helpful to have this affirmative reflected in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I especially like the tests.
Thanks, Jake and Adam! |
Hi all,
I've implemented the approach outlined by @benthestatistician here to solve that issue. Ben's description there captures what's happening pretty well, but to recap things broadly:
slm.fit.csr.fixed
has been renamedslm_fit_csr
, per Ben's recommendationThe$x^\prime x$ or
slm_fit_csr
function now ensures that the matrix (specificallyxprimex := t(x) %*% x
)passed toSparseM::chol()
is positive definite. To do this, scan the diagonal ofxprimex
for 0s and then remove the corresponding rows/columns fromxprimex
andxy
. This is done by creating a sparse matrix (via SparseM) that can be used to subsetxprimex
andxy
via some matrix multiplication. Things are then adjusted after the fact in order to fill in the removed elements. The helper functionsSparseM_solve()
andcreate_SparseM_reduction_matrix()
assist with these procedures. The main selling point here is that everything is handled with sparse matrices.I've added some tests for this second helper function to
test.utils.R
and updated the documentation to reflect the new names/functions. All tests pass for me now.(This PR also includes a fix for issue 124 -- perhaps we can close the request here and just include those changes here if that works.)