Hi all, I’m trying to run a multilevel model to estimate an electricity consumption time series for a building, but I’m having issues in generating the predictions once I obtained the trace.
My goal is to obtain hourly electricity consumption values depending on the moment of the day (daypart) and on the outdoor temperature, so I formulated this partial pooling model where I have an intercept and a temperature slope which are pooled among the different parts of the day.
with pm.Model(coords=coords) as partial_pooling:
daypart_idx = pm.Data(“daypart_idx”, daypart, dims=“obs_id”)
temperature = pm.Data(“temperature”, outdoor_temp, dims=“obs_id”)
a = pm.Normal(“a”, mu=0.0, sigma=10.0)
sigma_a = pm.Exponential(“sigma_a”, 1.0)
bt = pm.Normal(“bt”, mu=0.0, sigma=1.0)
sigma_bt = pm.Exponential(“sigma_bt”, 0.5)
a_daypart = pm.Normal(“a_cluster”, mu=a, sigma=sigma_a, dims=“Daypart”)
bt_daypart = pm.Normal(“bt_cluster”, mu=bt, sigma=sigma_bt, dims=“Daypart”)
mu = a_daypart[daypart_idx] + bt_daypart[daypart_idx] * temperature
sigma = pm.Exponential(“sigma”, 1.0)
y = pm.Normal(“y”, mu, sigma=sigma, observed=log_electricity, dims=“obs_id”)
partial_pooling_trace = pm.sample(random_seed=RANDOM_SEED)
partial_pooling_idata = az.from_pymc3(partial_pooling_trace)
My problem is that now I can’t seem to find the way to get from the estimated parameter distributions to the predictions. For example my goal would be to estimate what would the electricity consumption be at a certain hour of the day and given a certain outdoor temperature value.
All the notebook examples I found define a model, then obtain the trace by fitting the model using sampling or some other methods. None of the notebooks explains how to use that trace to obtain predictions. My idea is that this should happen through some kind of sampling from the obtained trace, but I’m not sure if I’m missing something important here.
Thanks a lot in advance for the help!