using rcpp to improve speed, but rewriting regressions in R improves 3x