wwrechard / pydlm

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

How to get forecast information for every draw from PyDLM? #69

Closed Simha-Kalimipalli closed 10 months ago

Simha-Kalimipalli commented 10 months ago

Hi There, Bayesian time series models typically return a 2d array of the forecast for every draw and every timestamp that is predicted. I skimmed through the documentation and I was not able to find a class method to get that info from my Pydlm model. Is there any way to retrieve this array from pydlm?

Thanks

wwrechard commented 10 months ago

Hi @Simha-Kalimipalli, this package is specialized for fast time series computation. Because of that goal, it used the Kalman filter to derive the marginal distribution at each timestamp (which is a Gaussian distribution because of the normal-normal prior assumption) instead of sampling the entire posterior series. You will be able to find the mean and variance of the marginal distribution using the provided APIs within the package.

However, if you do want to sample the posterior sequence of the fitted time series rather the marginal distribution at each step, then you will need to look at other packages (e.g., pybats which was implemented by the student of Dr. West). I did implement the backward sampling algorithm in this package but it never got used/exposed in the latter development because of the slowness and most people mostly care about marginal distribution for inferencing.

Simha-Kalimipalli commented 10 months ago

Thanks, I will look into the things that you mentioned!