I guess i don’t need scan for this task:
import numpy as npy
import pymc3 as pm
from theano import tensor as tt
Hd = npy.array([629.52234607, 18969.57367046, 238960.91467992, 328497.85275376])
rows = npy.array([2, 9, 37, 81])
tend = 21
dt = 0.25
tSeq = npy.arange(0, tend+dt, dt)
def logistic(L, x0, t=tSeq, k=500):
return L/(1+tt.exp(-k*(t-x0)))
""" Build model """
with pm.Model() as TempModel:
BoundedNormal = pm.Bound(pm.Normal, lower=1e-6, upper=1e6)
B = BoundedNormal('B', mu=0.01172, sd=0.001172, testval=0.01172)
C = BoundedNormal('C', mu=1.6, sd=0.16, testval=1.6)
D = pm.Normal('D', mu=6.2, sd=0.62, testval=6.2)
switchpoint = pm.Beta('switchpoint', alpha=1, beta=1, testval=0.5)
t2 = tend*switchpoint
Hult = BoundedNormal('Hult', mu=338e3, sd=338e2, testval=338e3)
Hn1 = 0.5*Hult*(1.-tt.exp(-1.*B*tSeq**C))
Hn2 = 0.5*Hult*(tSeq-t2)/(tSeq-t2+D)
Hn = Hn1 + logistic(Hn2, t2)
Hn_trim = Hn[rows]
Hm = pm.Deterministic('Hm', Hn_trim)
Hm_printed = tt.printing.Print('Hm_printed')(Hm)
sigma = pm.HalfNormal('sigma', sd=1)#, shape=len(rows))
H_obs = pm.Normal('H_obs', mu=Hm_printed, sd=sigma, observed=Hd)
trace = pm.sample()
Still getting the same error though unfortunately.
** Correction on original post: both components of the curve are non-linear **