Ricardo, thanks for your quick reply.
I have made the change you suggest, but still get the same error message.
The updated code follows.
def define_model(n_brands, n_days, poll_brand,
zero_centered_y,
measurement_error_sd):
"""PyMC model for pooling/aggregating voter opinion polls"""
model = pm.Model()
with model:
# priors
unanchored_house_bias = pm.Cauchy("unanchored_house_bias",
alpha=0, beta=10, shape=n_brands)
zero_sum_house_bias = pm.Deterministic('zero_sum_house_bias',
var=(unanchored_house_bias - unanchored_house_bias.mean()))
# temporal model
DRIFT = 0.0
INNOVATION = 0.15 # from experience ... day-to-day change distribution sigma
EARLY_DATA_ITEMS = 5
SIGMA = 2.0
educated_guess = zero_centered_y[:min(EARLY_DATA_ITEMS,
len(zero_centered_y))].mean()
start_dist = pm.Normal.dist(mu=educated_guess, sigma=SIGMA)
print(f'DRIFT: {DRIFT}, INNOVATION: {INNOVATION}, '
f'educated_guess: {educated_guess}, SIGMA: {SIGMA}'
f'\ninit: {type(start_dist)}')
grw = pm.GaussianRandomWalk('grw', mu=DRIFT, sigma=INNOVATION,
init=start_dist, steps=n_days) ### FAILS HERE
# the observational model
observed = pm.Normal("observed",
mu=grw[poll_day]
+ zero_sum_house_bias[poll_brand.to_list()],
sigma=measurement_error_sd, observed=zero_centered_y)
return model
You can see that I have added a diagnostic print statement, which tells me the type of the starting_dist is <class ‘aesara.tensor.var.TensorVariable’>
Any further thoughts or suggestions would be welcomed.