I have searched high and low for a practical example of using a particle filter to assist with short term price forecasting using the local trend of a time series.

Could someone please share how a particle filter could be applied to time series using MATLAB.

I greatly appreciate any help on this.

  • $\begingroup$ I am pretty good with Kalman and MatLab. I am not (yet) as good as I would like in "time-series", whatever that is. Can you give me some sample data? What can you tell me about the underlying system? Are you looking to minimize the errors in your parameter estimates? What is the goal? $\endgroup$ May 26, 2013 at 13:26
  • $\begingroup$ Some data can be found here. finance.yahoo.com/q/hp?s=%5EGSPC+Historical+Prices $\endgroup$
    – Dave
    May 31, 2013 at 5:12
  • $\begingroup$ Would you be able to show a simple example of how the unscented filter or particle (non linear) could be used to smooth the price series. $\endgroup$
    – Dave
    May 31, 2013 at 5:13
  • $\begingroup$ The RTS smooth using a Kalman filter is "textbook". Its major strengths are the simplicity of the formulation and the computation speed. There are much higher performance smoothers using MatLab, but they take more work. Here is a good text on the subject: amzn.com/0470173661 . Page 574 lists the Kalman filter based smoothers. RTS is the initial one. $\endgroup$ May 31, 2013 at 11:55
  • 1
    $\begingroup$ If the concern is for equities, particle filters are used in estimating stochastic volatility in Gibbs Samplers. $\endgroup$
    – John
    May 31, 2013 at 18:56

1 Answer 1


The primary idea behind a Kalman Filter is the optimal or nearly-optimal integration of an analytic model (and its errors) with real world measurements (and the associated measurement errors) to get a best estimate of both the most likely state and the uncertainty in this estimate.

I like to think of the following cartoon as a good way to describe this: Kalman cartoon

If you can provide the state update relationship then it is pretty straightforward to implement the Kalman filter. The "particle" or "unscented" are about handling the state estimate uncertainty. Given an initial state estimate $ \hat x_{n}(+)$ at time $ t(n)$ what is the function that produces the prediction $ \hat x_{n+1}(-)$ for time $ t(n+1)$? (using notation from pg number 190 on discrete-extended Kalman filters). What is "f"?

Would you think that assuming the value of the stock is constant over time is sufficient? Linear? Personally I like a system of four coupled 4th order ODE's. They have given me some good numeric results.

  • $\begingroup$ The movement of a stock or financial instrument is not linear at all. On some days (or times of day). A small or large push in one direction could be followed by an even larger consecutive move. Where as on other days this could be the complete opposite. Some interesting stuff here: tinyurl.com/kfau5vh $\endgroup$
    – Dave
    May 31, 2013 at 20:41
  • $\begingroup$ The "linear" would show how the system works with a "False model". I love the quote that "there is no perfect model, every model is inaccurate. there are, however many useful models". I find the "really bad model" of a constant (or linear) fit, integrated with the real world data, to be informative about the nature of the type of Kalman filter. Contrasting this with the results of a properly derived analytic model in analog to a statisticians null hypothesis is not entirely improper. $\endgroup$ May 31, 2013 at 21:16
  • $\begingroup$ Page 190 of what? $\endgroup$
    – naught101
    Jun 1, 2013 at 0:20
  • $\begingroup$ The link provided in the comment. A text on Kalman filters. $\endgroup$ Jun 1, 2013 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.