I’m trying to figure out why I am having a dimension mismatch here. It was my understanding that we could access the index of a shared variable to pass it along to another process. However, the line where “kappa” is declared kicks off an error due to a dimension mismatch. For some reason m1[build_idx] has dimension 64 rather than a dimension of 1 as expected. What am I missing? I could not find a good example in the documentation nor in any other reported issue. Thanks in advance!
Y = observations['z']
X = observations['x']
build_idx, build = pd.factorize(observations["building"], sort=True)
group_idx,group = pd.factorize(observations['group'],sort=True)
coords = {"group":group,"build":build,"obs_id":range(observations.shape[0])}
with pm.Model(coords=coords) as model:
# Setup indexing variables
build_idx = pm.Data("build_idx", build_idx, dims="obs_id")
group_idx = pm.Data("group_idx", group_idx, dims="obs_id")
x = pm.Data("x", X)
# Hyper-priors
m1 = pm.Uniform('m1',0,10, dims = 'build')
m2 = pm.Uniform('m2',0,10, dims = 'build')
s1 = pm.Uniform('s1',0,2, dims = 'build')
s2 = pm.Uniform('s2',0,2, dims = 'build')
kappa = pm.Normal("kappa", m1[build_idx], s1[build_idx], dims = "group")
llambda = pm.Normal("llambda",m2[build_idx], s2[build_idx], dims = "group")
k = kappa[group_idx]
l = llambda[group_idx]
# Cumulative Weibull distribution fit
b = pm.Deterministic("b", l**-k)
mean = pm.Deterministic("mean", 1-np.exp(-b*x**k))
std = pm.Uniform('std',0,10)
obs = pm.Normal('obs', mu=mean, sd = std, observed = Y)
with model:
trace = pm.sample(1000, tune=2000, chains=2,target_accept=0.99)