# Re: [R] Kalman Filter Forecast using 'SSPIR'

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Sun 18 Dec 2005 - 12:47:02 EST

I will herein outline the basics of Kalman forecasting. I have never used sspir, and I can't find all the hooks now to produce a forecast. Perhaps with this outline, you will be able to figure it out yourself, possibly by reading the code for some of the sspir functions.

The demo(vandriver) produces an "Extended" "SS" object "vd". When I try to print that model, it begins by reporting the following:

The state space model is given by

Y_t = F_t^T %*% theta_t + v_t, v_t ~ N(0,V_t) theta_t = G_t %*% theta_{t-1} + w_t, w_t ~ N(0,W_t)

for t=1,...,192

Kalman filtering can be described as Bayesian sequential updating, where the prior for the state for observation Y[t] is theta[t] ~ N(theta[t|t-1], Sig.theta[t|t-1]). Observation Y[t] is combined with this prior to produce the posterior N(theta[t|t], Sig.theta[t|t]). From this point, the forecasted distribution for theta[t+1] is N(theta[t+1|t], Sig.theta[t+1|t]), where

theta[t+1|t] = G_t %*% theta[t|t]
and

Sig.theta[t+1|t] = (G_t) %*% Sig.theta[t|t] %*% t(G_t) + W_t.

You can repeat this step any number of times to get N(theta[t+j|t], Sig.theta[t+j|t] for any j. With this, the forecast for Y[t+j] in the normal linear framework is N(F[t+j]^T %*% theta[t+j|t], Sig.y[t+j|t]) where

Sig.y[t+j|t] = t(F[t+j]) %*% Sig.theta[t+j|t] %*% F[t+j] + V[t+j]

This outline seems consistent with all the references on Kalman / state space with which I'm familiar, though the notation may be a little different. For more details including references, you can consult the "Foundations of Monitoring" material at "www.prodsyse.com".

If you would still like help from this listserve, please submit another post -- preferably after reading the posting guide! "www.R-project.org/posting-guide.html". Anecdotal evidence suggests that posts more consistent with that guide tend to get quicker, more useful replies.

```	  hope this helps.
spencer graves

```
```--

Sumanta Basak wrote:

> Dear R Users,

>
>
>
>                       I am new to state-space modeling. I am using SSPIR
> package for Kalman Filter. I have a data set containing one dependent
> variable and 7 independent variables with 250 data points. I want to use
> Kalman Filter for forecast the future values of the dependent variable
> using a multiple regression framework. I have used ssm function to
> produce the state space (SS) object, but I am bit confused that how can
> I predict the future values.
>
>
>
> Thanks a lot in advance.
>
>
>
>
>
> SUMANTA BASAK.
>
>
> -------------------------------------------------------------------------------------------------------------------
> This e-mail may contain confidential and/or privileged infor...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help

--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves@pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help