I’m tring to write down state space model in PyMC4 and sample posterior distributions of parameters as in PyMC3.
But the acceptance ratio of all variables are 0 and chain values do not change.
Is there some mistake in this code?
data=pd.read_csv("https://raw.githubusercontent.com/statsmodels/statsmodels/master/statsmodels/datasets/nile/nile.csv",index_col='year',)
N=len(data)
datay=np.array(data["volume"])
model = pm.Model(N=N, y=datay)
@model.define
def st(cfg):
mu0 = ed.Normal(name='muZero', loc=0.0, scale=1.0)
sigmaW = ed.InverseGamma(name='sigmaW', concentration=1.0, rate=1.0)
sigmaV = ed.InverseGamma(name='sigmaV', concentration=1.0, rate=1.0)
y=[0]*cfg.N
mu =[0]*cfg.N
mu[0] = ed.Normal(name='mu0', loc=mu0, scale=sigmaW)
for n in range(1, N):
mu[n] = ed.Normal(name='mu'+str(n), loc=mu[n-1], scale=sigmaW)
for n in range(N):
y[n]= ed.Normal(name='y'+str(n), loc=mu[n], scale=sigmaV)
return y
trace = pm.sample(model)