scikit-learn-contrib / skglm

Fast and modular sklearn replacement for generalized linear models
http://contrib.scikit-learn.org/skglm
BSD 3-Clause "New" or "Revised" License
158 stars 32 forks source link

Extension to linear autoregressive models #187

Closed mbignotti closed 1 year ago

mbignotti commented 1 year ago

Hi! I'm not super confident with sparse regression problems and related algorithms. Hence, I'm not really sure this question makes sense. However, I really enjoy the modularity and extensibility of skglm, and I would like to ask anyways. Do you think it makes sense to use it for autoregressive models?

A very basic example would be an ARX model: $y(t) = a{1}y(t-1) + ... + a{m}y(t-m) + b{0}u(t) + b{1}y(t-1) + ... + b_{p}u(t-p) + e(t)$

Thanks a lot!

mathurinm commented 1 year ago

Hi @mbignotti

I guess if you have $T$ time steps in total, you can construct the vectors $Y = (y{m +1}, ... y{T})$ and $x = (y1, ... y {T-1}, u_1, ..., u_T)$ and a (sparse) matrix $A$ such that your equation rewrites: $Y = Ax + e$ (deriving $A$ should not be too hard)

then you could fit than into skglm solvers, yes!

mbignotti commented 1 year ago

Now that I think about it, autoregressive models (AR, ARX, ARMA, ARIMA,...) can be converted in matrix form (to be precise, in state space form), but the conversion is non unique, as explained in the first answer to this question.

Here is an example for ARX models: https://math.stackexchange.com/questions/108524/convert-a-linear-difference-equation-into-a-controllable-state-space-model (Note the distinction between matrix $A$ and matrix $B$)

However, I'm not sure what the advantages/disadvantages of different representations are.

The likelihood function, then, is usually evaluated with the Kalman Filter and the parameters can then be estimated with solvers.

It's probably a bit more difficult than I thought.

In any case, thanks again for your answer!