ksimulate {sspir}R Documentation

Forwards filtering Backwards sampling

Description

Draws N samples from the conditional distribution of theta_1,...,theta_n given y_1,...,y_n in a Gaussian state space model.

Usage

ksimulate(ss, N = 1)

Arguments

ss an object of class SS with components m and C obtained from running kfilter.
N an integer giving the number of simulated realizations wanted.

Value

An array of dimension n times p times N. The i'th simulated state vector at time t is located in [t,,i].

Author(s)

Claus Dethlefsen and Søren Lundbye-Christensen.

References

C.K. Carter and R. Kohn (1994). On Gibbs Sampling for State Space Models. Biometrika, 3, 541-553.

See Also

ssm, kfilter, smoother.

Examples

data(kurit)
m1 <- SS(kurit)
phi(m1) <- c(100,5)
m0(m1) <- matrix(130)
C0(m1) <- matrix(400)

m1 <- kfilter(m1)
m1.s <- smoother(m1)
sim <- ksimulate(m1,10)

plot(kurit)
for (i in 1:10) lines(sim[,,i],lty=2,col=2)

lines(smoother(m1)$m,lwd=2)

[Package sspir version 0.2.3 Index]