tingiskhan/pyfilter

prior function error

andreanero opened this issue · 15 comments

Hi tingiskhan,

thanks for your effort.
I tried to run the stochastic-volatility.ipynb, but I am getting an error

student_t = DistributionWrapper(StudentT, df=Prior(Exponential, rate=0.1))
obs = AffineObservations((go, fo), (Prior(Normal, loc=0.0, scale=1.0)), student_t)

Error message:
raise ValueError("The parameter {} has invalid values".format(param))
ValueError: The parameter df has invalid values

Could you be so kind to explain me what I did wrong? Thanks again

Edit: sometimes it passes that line, sometimes not. Not understanding why the degrees of freedom are not accepted

Hi andreanero!

Thanks fot trying out the library. Hm, that's strange. What versions of Python and Pytorch are you using?

thanks for your reply!
First i used pycharm 2020.3.5 and python 3.8, torch is 1.8.1+cu102; then I tried also jupyter and then colab, but the result was the same...

Okay, it seems I get this error as well after having upgraded to 1.8.1. I'll fix it and add a test for it, thanks for reporting this!

Thanks to your support and effort! If I can help you I ll be more than glad!

No worries, just glad to see someone trying to use it! I've uploaded a new branch, try and see if you can use that instead - I'll merge it to master by tomorrow I think. I also added some clarification regarding the data fetching part of stochastic-volatility.ipynb as you'll need to replace some code with like Yahoo since it uses a private IEX token.

This is what broke everything btw.

You are right, I did modify the IEX part as well, just reading a csv with the data (I forgot to mention it).
If you want we can work on it and add eventually a nex example, since I d like to use it to calibrate a model with stochastic frequency for the a Poisson point process...

Thanks, seems to be corrected in the brench.
However running the following line:
logvol = m.Verhulst(*priors, dt=0.1, num_steps=10)
I got:
return self.rate.new(shape).exponential_() / self.rate
RuntimeError: "exponential_cpu" not implemented for 'Long'

Hmm, that's even weirder. Could you send the full stack trace? And does this happen every time you run the NB? Figured it had something to do when running the code on the CPU, but seems to be working for me.

And regards to the model you wish to implement: feel free to clone the repo and open a branch if you wish to try for yourself! Otherwise just link the article you wish to implement and I'll take a look at it.

Sorry, I just noticed your messsage. I tried to solve on my own, and after your last push everything seems to work correctly.
I am not using cuda, but cpu but I have a problem now with "'NewState' object has no attribute 'state'" which occurs when I try to run the line state = alg.fit(training) in stochastic-volatility.ipynb

No worries! Ah, right sorry about that: I introduced a breaking change when rolling out a general improvement. The .state attribute is now replaced with the slightly more fitting .values. Just install the latest version and replace .state with .values (or check the new Notebooks).

Thanks once again.
Replying asap, hoping everying ll work.

Hi tingiskhan, the hints you gave me are working fine!
Is there a way to direct messaging you? I am trying to extend your package to my case, but due to some lack of infos in building the class i am stuck. Thanks!

Hey again!

Great! Ah, right, the package is not very well documented (sorry about that), it’s on the to do list... I’d say that the easiest way would be to email me (you’ll find my email in the ‘setup.py’ file), and then we can take it from there.