Can't use GaussianRandomWalk output as sigma for another GaussianRandomWalk

Couple of things. GRW expects T on the right, and more importantly it doesn’t allow sigma to vary over steps.

You can use a CustomDist for your purpose or if the variable is not observed use the expression in the dist directly (defining the latent Normal as a model variable instead of using .dist):

def noise_varying_grw_dist(sigma, size=None):
  return pm.Normal.dist(0, sigma, size=size).cumsum(-1)  # or wherever time is

with pm.Model() as m:
  ...
  predictors_noise = pm.CustomDist(
    "predictors_noise",                
    sigma, 
    dist=noise_varying_grw_dist,
    shape=(N, T),
)

Disclaimer: untested code

1 Like