kfs {sspir} | R Documentation |
Runs the Kalman smoother on an ssm
object if the
family-attribute of the object is gaussian
. If not, the
iterated extended Kalman smoother is used.
kfs(ss, ...)
ss |
an object of class ssm . |
... |
further arguments passed to the Kalman smoother. |
The function is a wrapper for kfilter
followed by
smoother
in the Gaussian case. For other family types,
extended
is called. The kfs
function is called by
default in the call to ssm unless the option
\code{fit=FALSE} is given.
The returned value from either smoother
(Gaussian
case) or extended
.
Claus Dethlefsen and Søren Lundbye-Christensen.
kfilter
, smoother
,
extended
, ssm
.
data(mumps) index <- 1:length(mumps) phi.start <- c(0,0,0.0005,0.0001) m3 <- ssm( mumps ~ -1 + tvar(polytime(index,1)) + tvar(polytrig(index,12,1)), family=poisson(link=log), phi=phi.start, C0 = diag(4), fit=FALSE ) ## The option "fit=FALSE" means that the Kalman Filter/Smoother is not ## run. ## At this point you may inspect/change the setup before running 'kfs' C0(m3) C0(m3) <- 10*diag(4) ## incorporate possible structural 'jump' at timepoint 10 Wold <- Wmat(m3) Wmat(m3) <- function(tt,x,phi) { W <- Wold(tt,x,phi) if (tt==10) {W[2,2] <- 100*W[2,2]; return(W)} else return(W) } m3.fit <- kfs(m3) plot(mumps,type='l',ylab='Number of Cases',xlab='') lines(exp(m3.fit$m[,1]),type='l',lwd=2)