Hi,
Seems like a common sticking point, but I haven’t been able to find the help I need from past issues.
I am trying to define a custom likelihood and coming up against issues. The likelihood I would like to define is:
where \nu is a constant, I_j is the data and S_j is the model of the data.
I have defined the likelihood as follows:
def likelihood(theta1, theta2, theta3, nu, x, y):
'''
theta1-3 parameters
nu - constant
x,y - paired data
'''
mod_ = theta1*tt.power(x,-theta2)+theta3 #defines model
return -nu*((y/mod_)+tt.log(mod_)+(2/nu-1)*tt.log(y))
I have then instantiated a PyMC model:
with pm.Model() as model:
#prior
slope = pm.Normal('slope', 1, 1 )
amp = pm.HalfNormal('amp', 1 )
const = pm.Normal('const', 2e3, 100)
#likelihood
like = pm.DensityDist('like', likelihood, observed=dict(theta1=amp,theta2=slope,
theta3 = const,
nu=36,
x=x,
y=data_p))
and the MAP estimation functions works fine. However, when I try to sample, it appears to draw samples but crashes at the end. I get this error message:
MissingInputError: Input 0 of the graph (indices start from 0), used to compute Elemwise{exp,no_inplace}(amp_log__), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.
Somewhere, the parameter amp_log__ is being created, and is even returned in the MAP estimate:
{'slope': array(1.67333194),
'amp_log__': array(-0.96845745),
'const': array(1280.07218614),
'amp': array(0.37966824)}
Any ideas as to what I am doing wrong?
And, the summation present in the likelihood, do I need to specify in my definition of the likelihood function?