State Space Models in PyMC

Hi, this is an example of using scan for AR1-MA1 model with pymc3.

@DanWeitzenfeld @brandonwillard , could you elaborate more on why MA models require scan, while AR models not?

The AR(’‘p’’) model is given by the equation

y_t = \sum_{i=1}^p \phi_i y_{t-i}+ \varepsilon_t.\

And the MA(’‘q’’) refers to the moving average model of order ‘‘q’’:

y_t = \mu + \sum_{i=1}^q \theta_i \varepsilon_{t-i} + \varepsilon_{t}

It seems to me AR models also need scan when p >= 2.

In case of GaussianRandomWalk (GRW):

y_t = \mu_t
\mu_t = \mu_{t-1} + \eta_{t}

So, for the mu \mu_t here, it is similar to AR(p=1). In this case, we can use either at.cumsum or np.cumsum (as in here) to replace scan. But we cannot use cumsum for case like this one, right?

y_t = \mu_t
\mu_t = \phi_1 * \mu_{t-1} + \phi_2 * \mu_{t-2} + \eta_{t}

Thank you.