# NOT RUN {
## Generates T=500 observations from a linear state space model with
## ( phi, sigma_e, sigma_v ) = ( 0.5, 1.0, 0.1 ) and zero initial state.
d <- generateData(phi=0.5, sigmav=1.0, sigmae=0.1, T=500, x0=0.0)
## Estimate the filtered state
xhatf <- sm(d$y, phi=0.5, sigmav=1.0, sigmae=0.1, nPart=20,
T=500, x0=0.0)$xh
## Plot the estimate and the true state
par(mfrow=c(1,1))
plot(d$x, type="l", xlab="time", ylab="state")
lines(xhatf, lty="dashed",col="red")
# }
Run the code above in your browser using DataLab