I am modeling Generalised Extreme Value Distribution in PYMC3 but I keep on getting SamplingError: Initial evaluation of model at starting point failed! I am implementing my own distribution. The logp equation is the PDF of GEV. I took the inital values for the shape, location and scale parameters from the best guess by scipystats.
with pm.Model() as model:
#priors
shape = pm.Normal('shape', mu=shape1, sd=1.8*shape1)
loc = pm.Normal('loc', mu=loc1, sd=1.8*loc1)
scale = pm.Normal('scale', mu=scale1, sd=1.8*scale1)
def logp(value):
if (shape == 0):
lp=(np.log(1/scale) + (shape+1) * (-(value-loc/scale))- (-(value-loc/scale))).sum()
else:
lp=np.log(1/scale) + ((shape+1)*((-1/shape)*np.log(1+ shape*(value-loc/scale))))- ((-1/shape)*np.log(1+shape*(value-loc/scale))).sum()
return lp
gev = pm.DensityDist('gev', logp, observed = {'value':np.array(datin.data1)})
trace = pm.sample(3000, tune=500)
I am getting the following error:
SamplingError: Initial evaluation of model at starting point failed!
Starting values:
{'shape': array(-0.07499058), 'loc': array(14.728077), 'scale': array(5.38682189)}
Initial evaluation results:
shape -inf
loc -4.20
scale -3.19
gev NaN
Name: Log-probability of test_point, dtype: float64