Simpsons paradox and mixed models - large number of groups

I guess there’s a more subtle point here. The PyMC parameter x_hat is used in (part of) the likelihood. The python variable x_hat is defined, but never used thereafter. Even in simple models like the one you defined, it’s pretty customary to assign the likelihood to a variable:

mu = pm.Normal("mu")
    sigma = pm.HalfNormal("sigma")
    
    likelihood  = pm.Normal("likelihood", mu=mu, sigma=sigma, observed=my_data)
2 Likes