Appendix A. The forward filtering backward smoothing algorithm.
1) Forward filtering algorithm: The posterior and one-step forecast distribution in the NDLM can be calculated as follows:
a) Posterior at time t - 1: for some mean mt-1 and variance Ct-1, xt-1|Dt-1 N[mt-1, Ct-1].
b) Prior at time t: xt|Dt-1 N[at, Rt], where at = gmt-1 and Rt = g2Ct-1 + W.
c) One-step forecast: yt|Dt-1 N[st, Qt], where st = fat and Qt = f2Rt = V.
d) Posterior at time t: xt|Dt N[mt, Ct], with mt = at + Atet and Ct = Rt - A2tQt, where At = RtF/Qt and et = yt - st.
2) Backward smoothing algorithm: Given that p(xt|Dt) N[mt, Ct], for all k such that 1 k t, the filtering marginal distributions are
xt-k|Dt N[at(-k), Rt(-k)]
where Bt = CtgR-1t+1, at(-k) = mt-k + Bt-k[at(-k + 1) - at-k+1], and Rt(-k) = Ct-k+Bt-k[Rt(-k+1) - Rt-k+1]B't-k
with starting values at(0) = mt and Rt(0) = Ct, and where at-k(1) = at-k+1 and Rt-k(1) = Rt-k+1.