I am trying to implement in brms the rolling regression I found in the PyMC3 examples: https://docs.pymc.io/notebooks/GLM-rolling-regression.html
Briefly, the model looks like
GLD_T = \alpha_T + \beta_T *GFI_T
\alpha_t \sim \mathcal{N}(\alpha_{t-1}, \sigma_\alpha)
\beta_t \sim \mathcal{N}(\beta_{t-1}, \sigma_\beta)
so that the regression coefficients vary as a Gaussian random walk.
I thought I could use the non linear formulas in brms but I fear it is not possible. Below you find my attempt, which does not work (Error: Explicit covariance terms can only be specified on ‘mu’.). Would you be able to help?
library('tidyverse')
library('brms')
data <- read_csv('https://raw.githubusercontent.com/pymc-devs/pymc3/master/pymc3/examples/data/stock_prices.csv')
bf <- bf(
GLD ~ a + GFI*b,
nl = TRUE
) +
gaussian() +
lf(a ~ ar(p = 1)) +
lf(b ~ ar(p = 1))
EDIT: Just realized my question is similar to Possible to fit this time series model in brms?