I am trying to do inference with OrderedLogistic observations as per the following code
# Samples
yo = np.random.choice( np.arange(5), p=[0.1,0.25,0.05,0.4,0.2], size=500 )
# PYMC model
with pm.Model() as model_0:
# Priori
cutpoints= pm.Normal(
"cutpoints",
0.0,
1.5,
transform=pm.distributions.transforms.ordered,
shape=4,
initval=np.arange(4)
)
# Cumulative probabilities
q = pm.Deterministic( 'q', pm.math.invlogit(cutpoints) )
# Likelihood
Y = pm.OrderedLogistic("y", 0.0, cutpoints, observed=yo)
# Prior predictive
prior_ppc = pm.sample_prior_predictive( samples=1000 )
# Plot Prior predictive
fig, ax = plt.subplots( figsize=(15,5), ncols=3 )
_ = sns.kdeplot( prior_ppc.prior['cutpoints'][0,:], ax=ax[0] )
_ = sns.kdeplot( prior_ppc.prior['y_probs'][0,:], ax=ax[1] )
_ = sns.histplot( prior_ppc.prior_predictive['y'][0,:,100], stat='probability', ax=ax[2] )
The posterior results (not included in the code) look good, since the number of observations overshadow the priors. However the prior predictions do not make sense, since they predict negative probabilities for each category a priori.
Inspecting prior samples for the cutpoints of the model, it looks like the model is not sampling in increasing order as I would assume by the pm.distributions.transforms.ordered
I have tried different initvals for the Normal distribution, but it doesn’t change the output.
Any guidance would be helpful. Thanks!