Welcome | State space notation | Functions | > kalman.filter |
Last update Apr 29, 2003 |
DESCRIPTION:Kalman filter for Gaussian observations assuming linear Gaussian latent process. The specific model is
USAGE:kalman.filter(ssm)
REQUIRED ARGUMENTS:
OPTIONAL ARGUMENTS:The following attributes of the ssm object might be needed:
VALUE:Returns an object of class ssm with the same attributes as the object in the call, but with attribute filtered updated with:
SIDE EFFECTS:None
DETAILS:This is the standard Kalman filter.
REFERENCES:Durbin & Koopman, (2002), Time Series Analysis by State Space Models, Oxford Statistical Science Series.Fahrmeir & Tutz, (1994), Multivariate Statistical Modelling Based on Generalized Linear Models, Springer Series in Statistics. Klein, (2003),State Space Models for Exponential Family Data, Ph.D. Thesis, Department of Statistics, University of Southern Denmark. West & Harrison, (1997), Bayesian Forecasting and Dynamic Models, Springer Series in Statistics. EXAMPLES:# local level state space model ss <- ssm( Ft = function(i, x, phi) {matrix(1,1,1)}, Gt = function(i, x, phi) {matrix(1,1,1)}, Vt = function(i, x, phi) {matrix(80,1,1)}, Wt = function(i, x, phi) {matrix(10,1,1)}, m0 = c(20), C0 = matrix(50,1,1)) # simulate latent process and observations ss <- simulate.ssm(ss) # set prior ss$m0 <- c(0) # apply Kalman filter ss <- kalman.filter(ss) # plot like Figure 1.5, upper panel par(mfrow=c(2,1)) plot(ss$filtered$mt, ylim=c(-30,60), type="l", lty=3) lines(ss$filtered$mt+2*sqrt(ss$filtered$Ct[1,1,]),lty=2) lines(ss$filtered$mt-2*sqrt(ss$filtered$Ct[1,1,]),lty=2) lines(ss$simulated$theta,lty=1) # Exchange evolution and observation variances ss$Vt <- function(i, x, phi) matrix(10,1,1) ss$Wt <- function(i, x, phi) matrix(80,1,1) # Apply Kalman filter again ss <- kalman.filter(ss) # plot like Figure 1.5, lower panel plot(ss$filtered$mt, ylim=c(-30,60), type="l", lty=3) lines(ss$filtered$mt+2*sqrt(ss$filtered$Ct[1,1,]),lty=2) lines(ss$filtered$mt-2*sqrt(ss$filtered$Ct[1,1,]),lty=2) lines(ss$simulated$theta,lty=1) |