How could i use 3 random variables instead of one with shape=3 with pymc3

Hi, I am new to pymc3. I am trying to implement an unpooled model with 3 random variables (b0,b1,b2 ~ Normal) instead of one (b) with shape= 3. The code is from the book Bayesian Modeling and Computation in Python. Understanding how to do this it will help me implement a more complex multilevel model afterwards. I don’t know how to pass the three variables to the deterministic variable.

customers = sales_df.loc[:, "customers"].values
sales_observed = sales_df.loc[:, "sales"].values
food_category = pd.Categorical(sales_df["Food_Category"])

with pm.Model() as model_sales_unpooled:
    s = pm.HalfNormal("s", 20, shape=3)
    b = pm.Normal("b", mu=10, sigma=10, shape=3)
    
    m = pm.Deterministic("m", b[food_category.codes] *customers)
    
    sales = pm.Normal("sales", mu=m, sigma=s[food_category.codes],
                      observed=sales_observed)

You can stack your variables with pm.math.stack([a, b, c]). Note however that unless you need to use different prior distributions, it’s better to use a single distribution with shape=n, as that results in more efficient code.

Thanks a lot for your reply. Actually yes, I might use different prior distributions. I tried to do something similar with theano.tensor.stack. Is pm.math.stack more efficient?

They are exactly the same