Given a weekly time series
, I am trying to model it with MA(1) process with heteroscedastic innovation term, with the variance hidden be some random walk
df = pd.read_csv('data/h1weekly.csv',
parse_dates=['Date'],
index_col='Date',
dtype={'IsCanceled': float})
df.index.freq = 'W-SUN'
series = pd.Series(np.log(df['IsCanceled'])).diff().dropna()
data = series.values
with pm.Model() as model:
mu = pm.Normal('mu')
theta = pm.Normal('theta')
sigma = pm.GaussianRandomWalk('sigma', steps=len(data) - 1)
epsilon = pm.Normal("epsilon", sigma=pm.math.abs(sigma))
obs = pm.Normal('obs', mu=mu + theta * epsilon[:-1] + epsilon[1:], observed=data[1:])
idata = pm.sample(1_000, chains=4)
The file is located here: https://lp-prod-resources.s3.amazonaws.com/254/44009/2021-04-08-15-51-27/h2weekly.csv
I would like to know:
- how sensible is this model,
- how do I select good priors for it,
- how can I generate an graph similar to https://www.statsmodels.org/dev/_images/examples_notebooks_generated_statespace_sarimax_pymc3_10_0.png