wwrechard / pydlm

A python library for Bayesian time series modeling
BSD 3-Clause "New" or "Revised" License
475 stars 98 forks source link

longSeason nonworking? #44

Open mschmill opened 4 years ago

mschmill commented 4 years ago

I have some hourly data where there is a daily seasonality which I am modeling with a 24 hour seasonality component, but there is also a weekly seasonality that I would like to model. I believe that longSeason is the correct choice here, with a period of 7 and stay of 24. Here is my model:

import pydlm as dlm
the_dlm   = dlm.dlm(oc1819_tr.total) 
the_ar    = dlm.autoReg(degree=5, discount=0.99, name='ar_5', w=1e7)
the_trend = dlm.trend  (degree=1, discount=0.995, name='trend1', w=1e7)
the_daily = dlm.seasonality(period=24, discount=0.99, name='seasonal_daily', w=1e7)
the_weekly = dlm.longSeason(data=oc1819_tr.total, period=7, stay=24, name='seasonal_weekly', w=1e7, discount=0.99 )
dlm_model = the_dlm + the_ar + the_daily + the_trend + the_weekly

However, this causes a TypeError in the fit function which does not seem to be a configuration error:

TypeError                                 Traceback (most recent call last)
<ipython-input-148-c0cf1bf753dd> in <module>
      1 import timeit
      2 i = timeit.default_timer()
----> 3 dlm_model.fit()
      4 timeit.default_timer()-i

~/anaconda3/lib/python3.7/site-packages/pydlm/dlm.py in fit(self)
    281 
    282         """
--> 283         self.fitForwardFilter()
    284         self.fitBackwardSmoother()
    285 

~/anaconda3/lib/python3.7/site-packages/pydlm/dlm.py in fitForwardFilter(self, useRollingWindow, windowLength)
    183         # see if the model has been initialized
    184         if not self.initialized:
--> 185             self._initialize()
    186 
    187         if self._printInfo:

~/anaconda3/lib/python3.7/site-packages/pydlm/func/_dlm.py in _initialize(self)
    148         """
    149         self._autoNoise()
--> 150         self.builder.initialize(noise=self.options.noise, data=self.padded_data)
    151         self.Filter = kalmanFilter(discount=self.builder.discount,
    152                                    updateInnovation=self.options.innovationType,

~/anaconda3/lib/python3.7/site-packages/pydlm/modeler/builder.py in initialize(self, data, noise)
    275             for i in self.automaticComponents:
    276                 comp = self.automaticComponents[i]
--> 277                 comp.updateEvaluation(0, data)
    278                 transition = mt.matrixAddInDiag(transition, comp.transition)
    279                 evaluation = mt.matrixAddByCol(evaluation,

TypeError: updateEvaluation() takes 2 positional arguments but 3 were given

Could this be related to the fact that all components except longSeason no longer take a data argument?

mschmill commented 4 years ago

i guess nobody's home

Arjunh50 commented 4 years ago

Try to do a clone (As you would get the latest version) of the repository rather than PyPi installation, and then run longSeason.