-
Notifications
You must be signed in to change notification settings - Fork 7
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
Speed up alm function #14
Comments
After some experiments and digging: The only problem that is left is (1). |
vcov is now calculated only when the user asks for it. So (1) can be sort of ignored. But another problem is that alm() is still slower than lm() even for distribution="dnorm". It seems that this is because of the slow distribution functions that we use for the likelihood calculation (e.g. dnorm()). And the optimisation does not make things fast, but it needs to be there so that we get better estimates of parameters (especially for the weird distributions). |
Create parameter that allows skipping all the checks in alm(). This might speed up the process and simplify some calculations. |
Remove terms() and qr() - they are nor needed anymore. |
terms and qr are removed in cf0eb6b |
I relation to (2), I had a similar problem when constructing a basic LSTM. I found that using Rcpp provides a slight speed up to both matrix multiplication and outer product. I have both functions in my repo you can give them a try if you'd like. Please note that both can be used as either prefix and infix functions:
By the way.. Keep up the good work - I really enjoy your packages. :-) |
Thanks for the link! I've implemented functions like that at some point and compared the simple multiplication with the C++ one, but the difference was not significant. In fact, in some cases, the conventional %*% did better (I think this is due to improvements in R starting from 3.5.0). But this was done in Rcpp and in RcppArmadillo (two different functions). Is RcppEigen more efficient? Interesting package, by the way! Thanks! |
I implemented the functions in both Rcpp, RcppArma, and RcppEigen and found the Eigen version to perform best. However, my motivation for not using the conventional In terms of speed, I found a benchmark of RcppArma versus RcppEigen that shows Eigen to be faster than Arma when the matrices are mapped. Also, it shows that the time complexity of matrix multiplication with mapped Eigen matrices is lower, meaning that efficiency gains become more apparent with larger matrices. However, when I copy his code, I don't get the same results. Instead, I find that |
Thanks for the detailed explanation! It makes sense. |
alm() is slow for several reasons:
While (2) and (3) are doable, they won't fix (1). Not sure what to do with it...
The text was updated successfully, but these errors were encountered: