Hi, I was trying to run the following code:
import numpy as np
import pymc3 as pmc
x_missing = np.ma.masked_values([0, 2, 0, 1, 0, -999, 0, 1, -999], value=-999)
x_not_missing = [0, 2, 0, 1, 0, 0, 0, 1, 1]
N = len(x_not_missing)
model = pmc.Model()
with model:
a = pmc.Dirichlet('a', np.ones(3))
x = pmc.Categorical('x3', p=a, shape=N, observed=x_missing)
trace = pmc.sample(1000, step=pmc.Metropolis())
pmc.traceplot(trace)
And get the following output (with error)
Applied stickbreaking-transform to a and added transformed a_stickbreaking to model.
Assigned NUTS to a_stickbreaking
Assigned Metropolis to x3_missing
(...)
IndexError: index 3 is out of bounds for size 3 (...)
However, if I change the observed to x_not_missing, it works fine. Reading #1095, I see that it's most likely because PyMC assigns Metropolis to the x3_missing variable, which is categorical.
You have a mistake in your code. You should be passing a as the p argument to x.
Thanks for noticing! It was an artifact of my attempt to reduce the code to the minimal example. Just updated it, shouldn't interfere with the issue.
EDIT: The error message changes because we then revert to #881, but if we add step=pmc.Metropolis() we get the original error back. Edited in the main code.
I'm having the same issue here
I see the problem. The missing values are being attributed with the distribution NoDistribution, as we do with missing data. Will fix.
I tested it locally and it is not an issue anymore.
Most helpful comment
I see the problem. The missing values are being attributed with the distribution
NoDistribution, as we do with missing data. Will fix.