wwrechard / pydlm

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

Appending new data with AutoReg component #37

Open thk3421-models opened 5 years ago

thk3421-models commented 5 years ago

first, I just want to thank you for building this awesome library. Very impressive and extremely useful.

I'm running into a bug where I cannot append new data to a DLM that has an AutoReg component. If I build the model without the AutoReg component, everything works. Here is an example of the problem:

dlm = pydlm.dlm(data['gross_revenue'].values) dlm += pydlm.seasonality(period=7, w=0.95) dlm += pydlm.autoReg(degree=2, discount=0.95) dlm += pydlm.dynamic(features=[[x[0],x[1],x[2]] for x in features_matrix.values[:,:]], name='dau', discount=0.99) dlm.fit() #so far so good at this point.

dlm.append([new_data['gross_revenue']], component='main') #this line yields the following error: AttributeError: 'autoReg' object has no attribute 'appendNewData'

Perhaps I'm not implementing the update correctly? If I remove the AutoReg component, everything works. Any advice is greatly appreciated.

thk3421-models commented 5 years ago

I can see that longSeason.py has this method, which is an automatic component. Perhaps a similar method needs to be added for the autoReg component? Thanks for any help or advice.

wwrechard commented 4 years ago

Thanks for raising the issue. This is a bug. autoReg reads features from the main time series directly, so new need to call appendNewData here. Added a placeholder to mitigate the error.

thk3421-models commented 4 years ago

Thank you for the fix, I'll update and test it very soon. Much appreciated!