Welcome | State space notation | Functions | > kal.fil.po.log |
Last update Apr 29, 2003 |
DESCRIPTION:Extended Kalman filter for Poisson data assuming log link and linear Gaussian latent process. The specific model is
USAGE:kal.fil.po.log(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:The filter works by sequentially approximating the Poisson observation density with a Gaussian density based on a Taylor expansion around the values supplied in the attribute m.start of the ssm object. If m.start is not supplied, the Taylor expansion will be around the one-step forecast mean of the observation.
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. EXAMPLES:# Organize the data from the data frame vandrivers death <- vandrivers[,1] indi <- matrix(vandrivers[,2],ncol=1) # Design vector Ft <- function(i,Xt,phi) c(1,1, rep(0,10), Xt[1]) # Evolution transfer matrix Gt <- function(i, Xt, phi) { trend <- c(1, rep(0,12)) season <- cbind(0,rbind(rep(-1,11), cbind(diag(rep(1,10)),0)),0) seat <- c(rep(0,12),1) result <- rbind(trend,season,seat) result } # Evolution variance matrix Wt <- function(i,Xt,phi) { result <- matrix(0,nrow=13,ncol=13) result[1,1] <- phi result } # Initial prior parameterss C0 <- 1000*diag(rep(1,13)) m0 <- rep(0,13) # Specify state space model van.ss <- ssm(Ft=Ft, Gt=Gt, Wt=Wt, Xt=indi, phi=0.0245^2, m0=m0, C0=C0, Yt=death, fam="Poisson", link="log", m.start=NA) # Apply extended Kalman filter van.ss.fil <- kal.fil.po.log(van.ss) # Apply the iterated extended Kalman filter and smoother van.ss <- ieks(van.ss) # Sum trend and effect of seat belt legislation FFt <- function(i,Xt,phi) c(1, rep(0,11), Xt[1]) tmp <- matrix(NA, nrow=192, ncol=2) for (i in 1:192) { FF <- FFt(i,indi[i,],phi) tmp[i,1] <- FF%*%van.ss$smoothed$m.tilde[i,] tmp[i,2] <- t(FF)%*%van.ss$smoothed$C.tilde[,,i]%*%(FF) } # PRODUCE PLOT (like Figure 2.6) plot(exp(tmp[,1]), ylim=c(0,20), lty=1, type="l") lines(exp(tmp[,1]+2*sqrt(tmp[,2])), lty=3) lines(exp(tmp[,1]-2*sqrt(tmp[,2])), lty=3) |