Open mathause opened 1 month ago
Note also statsmodels
OLS is in between curve_fit
and linregress
:
from statsmodels.regression.linear_model import OLS
%timeit OLS(arr[1:], arr[:-1]).fit()
51.3 µs ± 266 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
note to self: can also be done for cycle-stationary AR process.
Thanks - I added OLS
above (interesting how your laptop is about 3-4 times faster; but it's also newer).
Estimating auto regression params is just an ordinary least regression in disguise (AFAIK). At least as long we don't do any fancy stuff and restrict ourselves to the standard AR(p) processes (no seasonal terms, estimating all the terms, ...). Switching from
AutoReg
to a linear regression solver can speed up the estimation (or more likely the data preparation) considerably (more than 10x). Of course we have to double and triple check the results. (Also I am a bit afraid that,AutoReg
checks for some edge chases we don't know about and that we will need to bells and whistles as soon as we rewrite it, but the speed gain could be worth it).See similarly #290 and https://github.com/MESMER-group/mesmer/issues/472#issuecomment-2211454603
Also, for
lag > 1
:edit: added OLS