[Rcpp-devel] Speeding up nlme::gls with temporal autocorrelation

Paul Thompson p1981thompson at gmail.com
Wed Oct 23 14:34:29 CEST 2019

Dear rcpp-dlevel members,

Hopefully, you may be able to shed some light on a problem that I have
regarding ‘speeding up’ the R function nlme::gls which I use for fitting
models with temporal autocorrelation. In a vignette by Doug Bates and Dirk
Eddelbuettel (
I found that they used RcppEigen to solve some least-squares problems, but
I wasn’t sure if this could be extended to generalised least squares?

The current function nlme::gls takes hours to execute and I was hoping to
use the Rcpp framework to ameliorate this problem, but I have little
experience in Rcpp or C++ programming and wasn’t sure if this had already
been tackled. After extensive searching on the web, I haven’t found any
implementation. Does anyone have any ideas or advice please?

My model syntax in R is currently as follows:

myfit <- gls(y~stim1+stim2+t+I(t^2)+I(t^3)+signal+stim1_signal,data=mydata,

Some other information, each time series has approximately 20,000

Thank you in advance for any help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20191023/2d747f5b/attachment.html>

More information about the Rcpp-devel mailing list