Howdy! I ran into some problems using coords and dims in my model.
“wavelength” is 131, “compound” is 10, “samples” is 25 in the following code.
coords = {"wavelength": spectra.columns,
"compound": conc.columns,
"samples": spectra.index
}
with pm.Model(coords=coords) as linearmodel:
#data
y = spectra.T.values
x = conc.T.values
#prior
sigma = pm.HalfCauchy("sigma", beta=5)
intercept = pm.Normal("intercept", 0, sigma=5, dims="wavelength")
slope = pm.Normal("slope", 0, sigma = 5, dims=("wavelength", "compound"))
#likelihood
likelihood = pm.Normal("y", mu= (slope @ x) + intercept,sigma=sigma, observed=y)
Im getting the following error code
"ValueError: Incompatible Elemwise input shapes [(131, 25), (1, 131)]"
for the sum of slope @ x and the intercept. If I replace dims=“wavelength” in the intercept for “shape=(131,1)” the code works as intended.
What would be the correct way to make this work using dims? I was under the impression that dims=“wavelength” or dims=("wavelength,) should make a (131,1) vector that would broadcast correctly.