# [PyMC3] Non-centered parameterization for rolling regression

Hi,

I am referring to this post https://docs.pymc.io/notebooks/GLM-rolling-regression.html to build a rolling regression time series model. My implementation as below is pretty straight forward. The problem is that even with 3000 samples, none of the variables converged (h_hat > 2 generally with 4 cores) and ess_means are generally less than 10.

I wonder if it’s because of the “funnel” problem and if there is a non-centered implementation for GaussianRandomWalk? (I know how to implement non-centered Normal, but GaussianRandomWalk doesn’t have an explicit “mu” parameter. )

Thanks in advance!

x_arr = np.array(X[regressors])
y_arr = np.array(y)
n_var = len(regressors) # number of variables - 4
n_t = X.shape[0] # number of timestamps - 108

with pm.Model() as linear_model:
# std of random walk
global_sigma = pm.Exponential(‘global_signma’, 0.05)

``````weights = pm.GaussianRandomWalk('weights', sigma=global_sigma, shape=(n_t, n_var))

noise = pm.HalfNormal('noise', sigma=2)

mu = (x_arr * weights).sum(axis=1)
y_observed = pm.Normal('y_observed',
mu=mu,
sigma=noise,
observed=y_arr)

posterior = pm.sample(3000, init="advi", target_accept=0.95)``````

Hi @yurong!

You can try the following:

``````pm.Normal('x', mu=0, sigma=sigma, shape=n).cumsum()
``````

To get a random-walk.

3 Likes

Thanks @twiecki! I’ll test this approach