Why does the standard deviation of the innovation term occur twice in PyMC Example, Forecasting with Structural AR Timeseries?

Hello,

First time posting here! :slight_smile:

I was working through the PyMC example, Forecasting with Structural AR Timeseries, when I noticed that the “standard deviation of the innovation term,” i.e., sigma, appears twice in the model definition.

priors = {
    "coefs": {"mu": [10, 0.2], "sigma": [0.1, 0.1], "size": 2},
    "sigma": 8,
    "init": {"mu": 9, "sigma": 0.1, "size": 1},
}

...

with pm.Model() as AR:
    pass

...
with AR:
    ...

    sigma = pm.HalfNormal("sigma", priors["sigma"])

    ...

    ar1 = pm.AR(
        "ar",
        coefs,
        sigma=sigma, # (HERE!)
        init_dist=init,
        constant=True,
        steps=t.shape[0] - (priors["coefs"]["size"] - 1),
        dims="obs_id",
    )

    # The Likelihood (AND HERE!)
    outcome = pm.Normal("likelihood", mu=ar1, sigma=sigma, observed=y, dims="obs_id")

    ## Sampling
    idata_ar = pm.sample_prior_predictive()
    idata_ar.extend(pm.sample(2000, random_seed=100, target_accept=0.95))
    idata_ar.extend(pm.sample_posterior_predictive(idata_ar))

Why does it appear twice?

Thanks for your help!

Welcome!

This specification uses a single parameter to control 2 different things. First, sigma controls the variability of the innovation term, as you note. However, it also controls the variability of the observed data around the mean (i.e., ar1). Could you have 2 parameters, one controlling each of these different roles? Sure. Perhaps someone who is more experienced with time series modeling can chime in with what is conventional in such applications.

1 Like

I would argue that the example is wrong. The sigma in the AR1 distribution corresponds to variance of the structural innovations, i.e. the exogenous shocks that push the time series around. The sigma in the Normal is more akin to measurement error: i.i.d. gaussian noise around the (true, latent) AR1 process. There’s no reason to believe these come from the same process. Even if we did, we shouldn’t want to bake that assumption into the model, because it’s so unusual.

I would encourage you to open an issue about it on the pymc-examples github repo, and potentially even submit a fix yourself :slight_smile:

1 Like

Thanks much for your responses! I’ll see if I can submit a fix