Hi all.
I am at the very early stages of translating a toolbox https://github.com/drbenvincent/delay-discounting-analysis from Matlab + JAGS, to Python + PyMC3. Unfortunately I’m falling at the first hurdle - so would really appreciate any insights about what I’m doing wrong here. I suspect that it’s a simple syntax issue, as I’m a novice with Python.
import pandas as pd
import pymc3 as pm
# minimal example data
df = pd.DataFrame({'A' : [80, 34, 25, 11, 49],
'DA' : [0, 0, 0, 0, 0],
'B' : [85, 50, 60, 30, 60],
'DB' : [157, 30, 14, 7, 89],
'R' : [0, 1, 1, 1, 0]})
basic_model = pm.Model()
with basic_model:
# Priors for unknown model parameters
logk = pm.Normal('logk', mu=-4, sd=3)
t = pm.Lognormal('t', mu=0, sd=10)
# Value functions
VA = pm.Deterministic('VA', df.A / (1.0+pm.math.exp(logk)*df.DA))
VB = pm.Deterministic('VB', df.B / (1.0+pm.math.exp(logk)*df.DB))
# Choice function: softmax
P_chooseB = pm.Deterministic('P', (VB*t) / pm.math.sum(pm.math.exp([VA*t,VB*t])))
# Likelihood (sampling distribution) of observations
R = pm.Bernoulli('R', p=P_chooseB, observed=df.R)
trace = pm.sample(njobs=2)
I get quite a long error message when trying to construct this model, so I’m not even at the ‘getting inference done’ stage yet. Any help is much appreciated.