# Random Walk in practice

I’ve been working through GLM-Rolling-Regression example by @twiecki and have a question about how to manage trade-offs between variance in intercept randowm walk vs. the regression itself. In the example this is hard-coded. My initial idea is to give the model a factor like so:

``````    std_ratio = pm.Lognormal('std_ratio', mu=4.0, sd=2.0)
sigma_intercept = pm.HalfCauchy('sigma_intercept', beta=10., testval=0.1)
intercept = pm.GaussianRandomWalk('intercept', sd=sigma_intercept, shape=lendata)
regression = intercept + slope * x

sigma = pm.Deterministic('sigma', std_ratio*sigma_intercept)
likelihood = pm.Normal('y', mu=regression[:-1], sd=sigma, observed=x[1:])
``````

Am I doing this wrong? Intuitively, I do not like for intercept to have a higher standard deviation than y…

You can also try model the total variance, and use a weight between [0, 1] to allocate the variance to the sigma of the intercept random walk vs. the sigma of the regression.

You can have a look at this answer for more details: Fitting Gaussian Random Walk to stock prices

Thanks for the suggestion. I can see how modeling the “big variance” + fraction is more stable than modeling two “small variances.”