Adding (time-varying) intercepts in gaussian_dlm_obs

Would it be possible to extend gaussian_dlm_obs to include time varying intercept? As in:

y_t \sim N(c_t+F'_t \theta_t ,V_t)
\theta_t \sim N(d_t + G_t \theta_{t-1}, W_t)
\theta_0 \sim N(m_0, C_0)

It is easy to by-pass the problem of c_t setting y_t^* = y_t -c_t , but it is kind of tricky to include d_t in the existing specification (also any suggestion on that point is more than welcome).

I’d try to do it myself but I literally just started with Stan and C++, so if some kind soul could take a look into it it would be greatly appreciated.

Cheers!

For intercept terms you can just add extra states to theta and modify the G or F matrices appropriately.

Thanks @Charles_Driver !
Thinking about your suggestion the only way I see to do it is something like that:

y_t =\alpha z_t + \theta_t +\epsilon, \epsilon \sim N(0, \sigma^2)
\theta_t =\beta x_t + \delta \theta_{t-1} + \omega, \omega \sim N(0, \rho^2)

becomes

y_t - \alpha z_t =\begin{bmatrix} 1 & 0 \end{bmatrix} \begin{bmatrix} \theta_t \\ 1 \end{bmatrix} + \epsilon, \epsilon \sim N(0, \sigma^2)
\begin{bmatrix} \theta_t \\ 1 \end{bmatrix} = \begin{bmatrix} \delta & \beta x_t \\ 0 & 1 \end{bmatrix} \begin{bmatrix} \theta_{t-1} \\ 1 \end{bmatrix} + \begin{bmatrix} \omega \\ 0 \end{bmatrix}, \omega \sim N(0, \rho^2)

with m_0 = \begin{bmatrix} \theta_0 \\ 1 \end{bmatrix}, C_0 = \begin{bmatrix} C_0 & 0 \\ 0 & 0 \end{bmatrix}.

Somehow, setting variances to 0 makes me uncomfortable. Never sure if it creates computational problems.
Please, if you have other, most likely smarter, options fell free to share.

In any case it would be nice to have the ability to specify the whole model directly.

Cheers,
F

The point is just to think of the time varying intercept as an extra process. To allow variation it will need some variance, and while the random walk formulation (diagonal temporal coefficient of 1) can make sense, it may also be better to estimate that term, and potentially also estimate the impact of theta1 on the intercept. Such a structure puts you in the realms of a second order linear process / damped linear oscillator. For identification you may need to set the innovation variance of theta1 to zero, but so long as theta2 (the tv intercept) has variance, this variance will feed into theta1 and there shouldn’t be numerical excitement. I’ve a continuous time example here –

the basic structure of the matrices is the same. Unless I somehow misunderstand you :)