2.3 Time-varying parameters

You can pass in an array of \(T\) matrices for a time-varying parameter. \(T\) is the number of time-steps in your data and is the 3rd dimension in the parameter array.
\[\begin{equation} \begin{gathered} \mathbf{x}_t = \mathbf{B}_t\mathbf{x}_{t-1} + \mathbf{u}_t + \mathbf{C}_t\mathbf{c}_t + \mathbf{G}_t\mathbf{w}_t, \quad \mathbf{W}_t \sim \,\text{MVN}(0,\mathbf{Q}_t)\\ \mathbf{y}_t = \mathbf{Z}_t\mathbf{x}_t + \mathbf{a}_t + \mathbf{D}_t\mathbf{d}_t + \mathbf{H}_t\mathbf{v}_t, \quad \mathbf{V}_t \sim \,\text{MVN}(0,\mathbf{R}_t)\\ \mathbf{x}_{t_0} \sim \,\text{MVN}(\boldsymbol{\pi},\boldsymbol{\Lambda}) \end{gathered} \end{equation}\] Note the time indexing. Make sure you enter your arrays such that the right parameter (or input) at time \(t\) lines up with \(\mathbf{x}_t\), e.g. it is common for state equations to have \(\mathbf{B}_{t-1}\) lined up with \(\mathbf{x}_t\) so you might need to enter the \(\mathbf{B}\) array such that your \(\mathbf{B}_{t-1}\) is entered at Bt[,,t] in the R code.

The length of the 3rd dimension must be the same as your data. For example, say in your mean-reverting random walk model (the example on the first page) you wanted \(\mathbf{B}(2,2)\) to be one value before \(t=20\) and another value after but \(\mathbf{B}(1,1)\) to be time constant. You can pass in the following:

TT <- dim(data)[2]
B1 <- array(list(),dim=c(2,2,TT))
B1[,,1:20] <- matrix(list("b",0,0,"b_1"),2,2)
B1[,,21:TT] <- matrix(list("b",0,0,"b_2"),2,2)

Notice the specification is one-to-one to your \(\mathbf{B}_t\) matrices on paper.