# Multiple independent random walks with differing innovations

Hi all,

I’d like to declare multiple Gaussian random walks which evolve independently. Following an earlier post asking about multiple drifts (Can I instantiate multiple random walks with different drifts), I tried:

``````mean_sigma = pm.HalfNormal('mean_rw_sigma', 1., shape=n_tourneys)
prior_means = pm.GaussianRandomWalk('prior_means', sigma=mean_sigma, shape=(n_years-1, n_tourneys))
``````

However, this doesn’t compile:

``````ValueError: Input dimension mis-match. (input[0].shape[1] = 3, input[1].shape[1] = 4)
``````

I thought I could maybe do the MvGaussianRandomWalk with a diagonal covariance, but I’ve been unable to create a diagonal covariance matrix, so I’d be grateful for any pointers. Apologies if I’m doing something silly, I’m pretty new to pymc3!

Thanks,
Martin

Could you raise an issue on Github? This use to work i think, but now `https://github.com/pymc-devs/pymc3/blob/2824027837931a6c2f1d4ac5f210eb36b8fdf7a7/pymc3/distributions/timeseries.py#L219-L225` makes it impossible.

1 Like

Using `pm.MvGaussianRandomWalk`:

``````import pymc3 as pm
import numpy as np
import theano.tensor as tt

n_timeseries, n_timepoint = 10, 100
with pm.Model():
mean_sigma = pm.HalfNormal('mean_rw_sigma', 1., shape=n_timeseries)
prior_means = pm.MvGaussianRandomWalk('rw', mu=np.zeros(n_timeseries), chol=tt.diag(mean_sigma), shape=(n_timepoint, n_timeseries))
``````
1 Like

Thanks for your quick help Junpeng! I’ve now raised an issue: Multiple independent random walks with differing innovation sds · Issue #4409 · pymc-devs/pymc3 · GitHub . That diagonal normal version should be a good workaround. I didn’t realise we can just use theano to manipulate tensors like that, that’s really great.