Because for-looping rbind with large matrices is slow, I replaced rbind with data.table::rbindlist. I don't like we have to use data.table::as.data.table and as.matrix for rbindlist but they seem necessary.
Ideally, it would be great if we can replace cbind in the for-loop too with something like cbindlist -- but it's not currently implemented in data.table (PR is https://github.com/Rdatatable/data.table/issues/2576). We can implement something similar to this function.
More ideally, if we could implement this model handling part within Rcpp space, that would be the most efficient
Because for-looping
rbind
with large matrices is slow, I replacedrbind
withdata.table::rbindlist
. I don't like we have to usedata.table::as.data.table
andas.matrix
forrbindlist
but they seem necessary.Ideally, it would be great if we can replace
cbind
in the for-loop too with something likecbindlist
-- but it's not currently implemented indata.table
(PR is https://github.com/Rdatatable/data.table/issues/2576). We can implement something similar to this function.More ideally, if we could implement this model handling part within Rcpp space, that would be the most efficient