PyMC3 example of NB regression in Code_8.21.py gives the following error message.
File "code_8.21.py", line 50, in
y = pm.NegativeBinomial('y', mu=pm.exp(eta), alpha=alpha, observed=y)
AttributeError: module 'pymc3' has no attribute 'exp'
I think that the pm.exp(eta) should be replaced with np.exp(eta).
I get the same result with Python2.7 and Python3.5.
I am using PyMC3 version 3.1.
After making the above change, the script runs for a much longer time and then throuws an error on line 54
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.
from pandas.core import datetools
Optimization terminated successfully.
Current function value: 3854.710331
Iterations: 31
Function evaluations: 48
Gradient evaluations: 48
Traceback (most recent call last):
File "./code_8.21.py", line 54, in
step = pm.NUTS(state=start) # Initiate sampling
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymc3/step_methods/hmc/nuts.py", line 149, in init
super(NUTS, self).init(vars, use_single_leapfrog=True, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymc3/step_methods/hmc/base_hmc.py", line 64, in init
vars, shared, model.logpt, self.potential, use_single_leapfrog, integrator, **theano_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymc3/step_methods/hmc/trajectory.py", line 124, in get_theano_hamiltonian_functions
energy_function, p = _theano_energy_function(H, q, **theano_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymc3/step_methods/hmc/trajectory.py", line 54, in _theano_energy_function
energy_function = theano.function(inputs=[q, p], outputs=total_energy, **theano_kwargs)
TypeError: function() got an unexpected keyword argument 'state'