Welcome | State space notation | Functions | > ckal.fil.po.gam.log |
Last update Apr 29, 2003 |
DESCRIPTION:Conjugated Kalman filter for Poisson data assuming log link and partially specified linear latent process. The conjugated prior on the mean parameter is gamma. The specific model is
USAGE:ckal.fil.po.gam.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:This is the conjugate filter introduced for the class of dynamic generalized linear models by West, Harrison and Migon (1985). Instead of approximating the observational model with a Gaussian one like in the extended Kalman filter, the latent process guides the choice of the conjugate prior on the natural parameter.
REFERENCES: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. West, Harrison & Migon, (1985),Dynamic Generalized Linear Models and Bayesian Forecasting (with discussion), Journal of the American Statistical association, 80, 73-97. 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 the conjugated filter van.ss <- ckal.fil.po.gam.log(van.ss) # Apply the Kalman smoother van.ss <- kalman.smoother(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) |