Many groups#

from drcurves.simulate import sim_hierarchical
df, _, _ = sim_hierarchical(seed=0)         # region, store, x0..x2, A, Y

model = fit_dose_response(df[["x0", "x1", "x2"]], df["A"], df["Y"],
                          groups=df[["region", "store"]])       # top -> bottom
store, se = model.curve(grid, ("r0", "r0_s03"))   # a store's curve, shrunk toward its region
region, _ = model.curve(grid, ("r0",))
new, _ = model.curve(grid, ("r0", "unseen"))      # a new store gets its region's curve
model.plot(paths=[("r0",), ("r0", "r0_s03")])

Your data

groups=

What you get

One population

None

One curve

Groups, no hierarchy

df[["store"]]

One curve per store, shrunk toward the overall curve

Nested hierarchy

df[["region", "store"]]

Stores shrunk toward their region, regions toward the overall curve

Levels must be nested; crossed groupings (store × channel) aren’t supported. Shrinkage acts on each group’s shape; its overall level is left nearly free. path=None under partial pooling is a “typical group” curve; for the population average, fit with groups=None.