Custom likelihood function giving TypeError


New to Bayesian modeling, tried to find an answer from previous posts but failed.

Each point of my observed data has two entries: years of work experience, and a boolean about whether they moved to a different state since they got their first job(0 if they did, 1 if they did not). For the people who stayed in the same state, the likelihood function is:

P(t|a,b) =e^{f1+f2}\\ f1=\frac{-b}{a^2}\\ f2=\frac{be^{-at}(1+at)}{a^2}

The likelihood function of people who have moved is obviously 1 minus this. My code is:

import pymc3 as pm
import theano.tensor as tt

yr = [20, 34, 8, 15, 38]    #years of work experience
ss = [1, 1, 1, 1, 0]        #0: didn't move states, 1: moved states

def likelihood(a, b, t, ss):
    f1 = -b/(a**2)
    f2 = (b*tt.exp(-a*t)*(1+a*t))/(a**2)
    return ss*(f1+f2)+(1-ss)*(tt.log(1-tt.exp(f1+f2)))   #logp

with pm.Model() as model:    
    a = pm.Gamma('a', alpha=1, beta=1)
    b = pm.Gamma('b', alpha=1, beta=1)
    like = pm.DensityDist('like', likelihood, observed={'a':a,'b':b,'t':yr,'ss':ss})
    trace = pm.sample()

This gives me an error:

Unknown parameter type: <class 'theano.tensor.var.TensorVariable'>

What am I doing wrong here? Thanks in advance.

I am getting another error:

MissingInputError: Input 0 of the graph (indices start from 0), 
used to compute Elemwise{exp,no_inplace}(a_log__), 
was not provided and not given a value. Use the Theano flag 
exception_verbosity='high', for more information on this error.

Try updating to latest arviz version and use idata_kwargs={"density_dist_obs": False} in pm.sample.

Note: I also recommend using return_inferencedata=True. Otherwise, this same error will be triggered any time you call plotting functions such as plot_trace or stats functions such as summary with this trace object.

The error is in the conversion to InferenceData step, because the variables passed as observed to DensityDist are not observed data, there are model parameters which works for sampling but ends up breaking things down the line. You may also want to track [WIP] Add givens argument to DensityDist by OriolAbril · Pull Request #4433 · pymc-devs/pymc3 · GitHub.

All plotting and stats functions do this conversion under the hood before doing the actual calculations or plots and do not allow to use extra arguments in the conversion step. Converting to inferencedata and calling plots and stats functions with an inferencedata object avoids first the conversion overhead and possible errors such as this.