I am trying to find the underlying ‘hidden’ price of a stock by modelling it as a Gaussian Random walk for the past 100 days. This is the model that I have:
n_samples = 500
with pm.Model() as model:
σ = pm.Exponential('σ', 1/np.abs(np.diff(y,axis=0)).mean())
f = pm.GaussianRandomWalk('f', sd=σ, shape=len(y))
sd = pm.Bound(pm.Normal, lower=0.0, upper=0.1)('sd', mu=0.0, sd=1.0, testval=1.0)
likelihood = pm.Normal('y', mu=f, sd=sd, observed=y)
trace = pm.sample(n_samples, njobs=4)
However ‘f’ simply ends up being zero. I bounded sd
because it was an attempt to make it ‘stick’ to the observed prices a bit better. Having it unbounded didn’t improve or worsen the model. Any thoughts on how I could improve this model? The full code is here, (see cell 27/28).