Yes but you don’t sample from the df_data["numerical_predictor"] it uses that deterministically. What is happening is something like this:
import numpy as np
import pymc as pm
predictor = np.linspace(-1, 1, 200)
with pm.Model(coords={"obs": range(len(predictor))}) as m:
coefficient = pm.Normal("coefficient", 0, 1)
mu = pm.Deterministic("mu", coefficient * predictor, dims="obs")
idata = pm.sample_prior_predictive(draws=1000)
pm.plots.plot_posterior(idata, group="prior")
With numpy the way you generate a similar thing is you take a 1000 draws of coefficient and then outer multiply with the predictor to get mu draws with shape (1000, 200)
Every order_amount has a different mu, because every order_amount has a different value of age_group and numerical_predictor. What you are seeing is the same as if you did e.g. res.predict(X) in statsmodels (or predict mu in STATA)
Sorry for one last question here, just for making it completely clear to me what happens during the plotting. Would you agree that one of these 40 mu-plots could be created by something like this?
What I want to understand here is that if the plotting itself (in contrast to the generation of the idata[“prior”] group with its mu data variable) has in itself a sampling part, which is sampling from this mu data variable and then estimates this kde which is plotted.
Yes, although arviz works directly on the inferencedata with the batch dimensions in a vectorized manner.
Under the hood the, 500x samples of each 200x mu are used separately do sketch the 200 kdeplots (of which arviz only bothers to plot the first 40 by default)