Thank you for the response!
Thanks for the pm.Censored(() example, my other solution appears to hang whilst sampling.
I currently have the following solution which provides ‘reasonable’ numbers for a.
with pm.Model() as cat_censored_m:
days_to_event = np.array(cats['days_to_event'],dtype=float)
adopted = np.array([1 if x == 'Adoption' else 0 for x in cats['out_event']])
black = np.array([0 if x == 'Black' else 1 for x in cats['color']])
a = pm.Normal('a', 0, 1,shape=2)
log_rate = 1/a[black]
upper_censoring = days_to_event.copy()
upper_censoring[adopted==0] = np.inf
y_obs = pm.Censored(
'y_obs',
pm.Exponential.dist(lam=log_rate),
lower = None,
upper=upper_censoring,
observed=days_to_event,
)
cat_censored_trace = pm.sample(initvals={'a':np.array([10,10])})
I had to set the initvals otherwise it would fail when trying to sample below 0.
Unfortunately this appears to be giving me an erroneous result. I expect the Black cats to have a higher, more dispersed a distribution. As shown in the lecture here. However I obtain the following distribution (a[0] == black cats). Any insight as to what’s going on?
