where wt⊥vt. Consequently the state noise covariance matrix is Q=sQsQ′ and the observation noise covariance matrix is R=sRsR′ and sQ,sR do not have to be square as long as everything is conformable.
xt is p-dimensional, yt is q-dimensional, and ut is r-dimensional. Note that sQwt has to be p-dimensional, but wt does not, and sRvt has to be q-dimensional, but vt does not.
Returns
Xs: An array of sampled states
X0n: The sampled initial state (because R is 1-based)
Source
Chapter 6 of the Shumway and Stoffer Springer text.
References
You can find demonstrations of astsa capabilities at FUN WITH ASTSA.
The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
Author(s)
D.S. Stoffer
Note
The script uses Kfilter. If At is constant wrt time, it is not necessary to input an array; see the example. The example below is just one pass of the algorithm; see the example at FUN WITH ASTSA for the real fun.
Examples
## Not run:## -- this is just one pass --### generate some data set.seed(1) sQ =1; sR =3; n =100 mu0 =0; Sigma0 =10; x0 = rnorm(1,mu0,Sigma0) w = rnorm(n); v = rnorm(n) x = c(x0 + sQ*w[1]); y = c(x[1]+ sR*v[1])# initializefor(t in2:n){ x[t]= x[t-1]+ sQ*w[t] y[t]= x[t]+ sR*v[t]}## run one pass of FFBS, plot data, states and sampled states run = ffbs(y, A=1, mu0=0, Sigma0=10, Phi=1, sQ=1, sR=3)tsplot(cbind(y,run$Xs), spaghetti=TRUE, type='o', col=c(8,4), pch=c(1,NA))legend('topleft', legend=c("y(t)","xs(t)"), lty=1, col=c(8,4), bty="n", pch=c(1,NA))## End(Not run)