Poisson regression divide by zero

I am trying to fit the following model:

import pymc3 as pm
basic_model = pm.Model()

with basic_model:
  exposures = pm.HalfNormal('exposures',sigma=2000,shape=(nSigs,nSamps))
  y = pm.math.dot(sigs,exposures)
  Y_obs = pm.Poisson('Y_obs',mu=y,observed=k)
  trace = pm.sample(1000,cores=12,return_inferencedata=False)

My observations, k, range from 0 to 1,000,000 with mean around 2000. sigs are values on (0,1) and sum to 1 across columns. When I run the model, it gets about 25% of the way through and then crashes with:

ValueError: Mass matrix contains zeros on the diagonal.
The derivative of RV exposures_log__.ravel()[2] is zero.
The derivative of RV exposures_log__.ravel()[15] is zero.
The derivative of RV exposures_log__.ravel()[21] is zero.
The derivative of RV exposures_log__.ravel()[38] is zero.

Any ideas?

Sounds like you could also use a Multinomial distribution as likelihood?
Otherwise, you might have overflow issue with k, range from 0 to 1,000,000 - you can try scaling k by some constant (i think the Poisson likelihood still works)

1 Like