DESCRIPTION:
Kalman smoother for Gaussian observations assuming
linear Gaussian latent process. The specific model is
USAGE:
kalman.smoother(ssm)
REQUIRED ARGUMENTS:
 ssm:
 Object of class ssm (state space
model) which have been returned by an appropriate filter.
The following attributes must be specified in ssm object:
 Yt:
 1 × n vector containing the binomial observations.
 Ft:
 Function returning a p × 1 design vector.
 Gt:
 Function returning a p × p evolution transfer matrix.
 Vt:
 Function returning the observation variance.
 Wt:
 Function returning a p × 1 evolution variance
matrix.
 m0:
 p × 1 vector (prior mean).
 C0:
 p × p matrix (prior variance).
 filtered:
 List containing the results obtained by running
the appropriate extended Kalman filter.
OPTIONAL ARGUMENTS:
The following attributes of the ssm object might be needed:
 Xt:
 Matrix containing the covariates needed in Ft,
Gt and/or Wt. This matrix must have n rows, such that
row t contains the covariates needed for generating the system
matrices at time t.
 psi:
 Parameter vector must be supplied if it is needed in
the calculation of the system matrices.
The following attributes of the ssm object are optional:
 fam:
 Tacitly assumed to have value Gaussian.
 link:
 Tacitly assumed to have value identity.
VALUE:
Returns an object of class ssm with the same
attributes as the object in the call, but with attribute
smoothed updated with:
 m.tilde:
 Posterior means ~m_{t} given all the
observations. These are arranged rowwise in a matrix.
 C.tilde:
 Posterior variances ~C_{t} given all
observations. These are arranged in a 3dimensional array such that
~C_{t} is placed in filtered$Ct[,,t].
SIDE EFFECTS:
None
DETAILS:
This is the standard Kalman smoother.
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 and Kalman smoother
ss < kalman.filter(ss)
ss < kalman.smoother(ss)
# plot like Figure 1.8, upper panel
par(mfrow=c(2,1))
plot(ss$smoothed$m.tilde, ylim=c(30,60), type="l", lty=3)
lines(ss$smoothed$m.tilde+2*sqrt(ss$smoothed$C.tilde[1,1,]),lty=2)
lines(ss$smoothed$m.tilde2*sqrt(ss$smoothed$C.tilde[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 and Kalman smoother
ss < kalman.filter(ss)
ss < kalman.smoother(ss)
# plot like Figure 1.8, lower panel
plot(ss$smoothed$m.tilde, ylim=c(30,60), type="l", lty=3)
lines(ss$smoothed$m.tilde+2*sqrt(ss$smoothed$C.tilde[1,1,]),lty=2)
lines(ss$smoothed$m.tilde2*sqrt(ss$smoothed$C.tilde[1,1,]),lty=2)
lines(ss$simulated$theta,lty=1)
