Dear Community,
I have a problem when I try to forecast using a Gaussian Random Walk.
When I try to update the data using the “set_data” method to generate a new time series, it still performs on the old sample(). What i want is to compare my in-sample to my out-of-sample but this didn’t work.
I try to create 60 new Values to make a forecast but it still return only a posterior for the initial 30 days. I don’t know how can I update the “shape” input Value of the “pymc3.GaussianRandomWalk()”
Thanks in advance!
My Model below
observedPricesAll = observedPrices
observedPrices = observedPrices.iloc[:30]
print(observedPrices)
## timeseries Model
with pymc3.Model() as testModel:
timeData = pymc3.Data("index",observedPrices['index'].values)
priceData = pymc3.Data("preisProQm",observedPrices['preisProQm'].values)
#Priors
driftBound = pymc3.Bound(pymc3.Normal,lower=-0.5)
drift = driftBound("drift",mu=0.0,sigma=0.05)
std = pymc3.HalfNormal("std",sigma=0.05)
# Stochastic Process
stochProcess = pymc3.GaussianRandomWalk("gaussianRandom",mu=drift,sigma=std,shape=len(observedPrices))
# Likelihood
likelihood = pymc3.Normal("like",mu=stochProcess,sigma=std,observed=priceData)
# Prior Predictive Check
with testModel:
priorPred = pymc3.sample_prior_predictive()
fig,ax= plt.subplots(figsize=(12,8))
ax.plot(priorPred['like'].T,color="0.5",alpha=0.5)
## Fit Model
with testModel:
traceTestModel = pymc3.sample(1000,chains=4,cores=4,tune=5000,return_inferencedata=True)
## Posterior Predictive Check
with testModel:
postPred = pymc3.sample_posterior_predictive(traceTestModel)
## Forecasting
with testModel:
pymc3.set_data({'index':np.arange(60),
'preisProQm':np.zeros(60)})
with testModel:
postPred = pymc3.sample_posterior_predictive(traceTestModel['posterior'],model=testModel)