tingiskhan/pyfilter

Structural Time Series - S.T.S

waudinio27 opened this issue · 7 comments

Hello Khan,

I wanted to tell you that I still think that this is an amazing package. I was suprised to see that you could make some updates, even so you became a father a short time ago.

Are there plans to add a structural time series like in Tensorflow Probability as well?

https://www.tensorflow.org/probability/examples/Structural_Time_Series_Modeling_Case_Studies_Atmospheric_CO2_and_Electricity_Demand

Is it possible to make predictions with the lynx hare example with VI, or the nutria example? And how could the nutria example be used for other data like weather?

And one more question - would it make sense to add a AR component-parameter as well to the stochastic volatility example to improve the prediction? Or even better add a parameter for resistance like in the SVL example -

https://github.com/mfrdixon/ML_Finance_Codes/blob/master/Chapter7-Probabilistic-Sequence-Modeling/ML_in_Finance-Kalman_Filters.ipynb

rho = pm.Uniform(name='rho', lower=-1., upper=1.)

I am still studying all this and try to improve my skills, and hope to make some contribution to the pyfilter as well in the future. Because I can say that I like it a lot.

Hey again!

First off: so sorry that I haven't produced the Notebook as promised, if it's still of interest I'll send you one when I have the time (going on parental leave this June, so that might be a good fit). Hehe, yeah, some late nights!

Have considered the STS part (adding seasonality etc), but just not gotten around to it, so perhaps in the future! The VI currently does not support predictions, but it's something that should be supported. The PMCMC algorithm used in nutria should support predictions! It could be I guess, I implement a Lorenz-63 (I think) system in lorenz.ipynb, and I think the 96-version is/was commonly used for weather modelling.

By resistance, I'm guessing you meant persistance? In pyfilter's SV model example the persistance parameter is captured by kappa (it's kind of an AR process with stochastic persistance and volatility).

Glad to hear! You're free to open up a PR with changes :-)

The STS would be great, but would probably take a lot of work.

So cool - now I get what the kappa parameter is used for :-D

You are right, it is the Lorentz model 93. Until now I only saw an implementation in the form of a GAN on GitHub.

To be honest, I want to try all the models - VI with prey and predator; the nutria and the Lorentz with market data. :-D.
For me they are semi-chaotic systems - just like the market! So if you update one with the prediction and post it here, I will be ready to try it. :-D

For example, the VI model with prey and predator could resemble a pairs trading strategy without parameters or a threshold. If you could show an example like this with prediction in the future, and a graphic that plots the outcome, I will appreciate it a lot. But as I read your answer again, and the predictions are currently not supported, it is also something for some day in the future.

Greetings Matthias - I hope you will enjoy the parental leave at the seaside

Okay I will start a tutorial about Pytorch and I will use the VI with meanfield approximation as a reference to build a notebook for the stock market with Close price in the future! Maybe even multivariate. No action requiered from your side.

Thanks a lot and greetings :-D

Hey again!

Sorry for the late reply... again.

Haha, yes, might do that - which inspired me to break out the timeseries module to structure the project better, and also integrate other inference libraries (read pyro.ai).

Absolutely, I can add a prediction part to the Lorenz notebook as I'm currently redoing the entire library.

Sounds great! Be sure to check out the separate timeseries library here: https://github.com/tingiskhan/stoch-proc/, see some of the examples.

Hello, Hello!

I think that this is a wonderful idea :-D If you break up everything a bit into different modules, it will be more comprehensive. Even though I understand that it also has an advantage to stack everything into one place.

I maybe will learn pytorch one day; but it I am not sure when this day will arrive. :-D

Meanwhile, I have put stock market data into the example of VI from PyMC. Just like I said, I will try to build something with meanfield approximation.

https://github.com/waudinio27/Bayesian-Neural-Network-with-PyMC3/blob/main/PyMC%20VI%20Neural%20Network%20only%20posterior.ipynb

Only the average loss = inf :-D ...... So not sure what is really going on there. Still it is a good start.

I will take a close look at stoc-proc for sure!

Cheers and Greetz

If you are redoing everything again and are able to add a notebook with meanfield approximation for stock market data I will try it out with delight. To set up a S.T.S is complex and that is why I am more looking into something like this at the moment ....
I also have a kid and from this I cannot find a lot of extra time. That is why I had to adopt a bit the plans.
From this point of view also a posterior is more than enough I found out somehow :-D

What you think about this?

Greetings M.

Maybe an S.T.S is not in the scope of pyfilter. Time to close the issue.