RfastOfficial / Rfast2

A collection of Rfast2 functions for data analysis. Note 1: The vast majority of the functions accept matrices only, not data.frames. Note 2: Do not have matrices or vectors with have missing data (i.e NAs). We do no check about them and C++ internally transforms them into zeros (0), so you may get wrong results. Note 3: In general, make sure you give the correct input, in order to get the correct output. We do no checks and this is one of the many reasons we are fast.
38 stars 4 forks source link

`leverage` with sparse matrix #22

Open kylebutts opened 1 year ago

kylebutts commented 1 year ago

Hi there!

I'm wondering if it's possible to have a version of the leverage function that operates on sparse matrices?

I'm trying to compute leave-out standard errors (https://github.com/rsaggio87/LeaveOutTwoWay) for a high dimensional fixed-effect model, so loading the matrix into memory isn't feasible

ManosPapadakis95 commented 1 year ago

We would love to deal with sparse matrices. Many have asked it before. Unfortunately the sparse matrices hide many problems (in the area of mathematics) and we don't have the time to learn and deal.
After some research, I found what you want but you have to use other packages.

Crossprod for sparse: https://stackoverflow.com/questions/71972327/sparse-matrix-as-a-result-of-crossprod-of-sparse-matrices

Mahalanobis distance for sparse: https://rdrr.io/cran/DiPs/man/maha_sparse.html