I am having trouble setting up a Categorical model with the dependence that interests me.
For background, I have a probability which I observe to be an exponentially decaying function of some continuous observable parameter b. So I have a series [b, s] where I observe a binary state s given the continuous parameter b. I am not sure that a logistic regression will correctly capture the dependence on b that I am seeing, so I want to try another approach.
So I want to try modeling the probability as a beta function with a mean that depends on b.
Regardless of whether or not this will be an effective model, I should be able to set it up in pymc3, but I’m running into trouble. In reality I have thousands of samples, which is why I would rather have a continuous dependence on b rather than a bucketed dependence.
Here is a toy example of what I’m trying to do:
import numpy as np
import pandas as pd
import pymc3 as pm
b = np.array([100, 120, 150, 200, 1000, 10000, 15000])
s = np.array([1, 0, 1, 1, 0, 0, 0])
s = pd.Categorical(s).codes
model = pm.Model()
with model:
sd = pm.HalfNormal('sd', sd=1)
l1 = pm.HalfNormal('l1', sd=100)
drift = tt.exp(-l1*b)
p1 = pm.Beta.dist(balance_drift, balance_sd)
obs = pm.Categorical('obs', p=tt.stack([p1, 1.-p1]), observed=s)
The error I observe is
TypeError: unsupported operand type(s) for -: 'float' and 'Beta'