Hi, I am trying to replicate Ruby Hierarchical model and get an error: “index must be integers”. I was following the example step by step, just with the newer data and not quite sure what is happening.
here model:
with pm.Model() as model:
# global model parameters
home = pm.Flat("home")
sd_att = pm.HalfStudentT("sd_att", nu=3, sigma=2.5)
sd_def = pm.HalfStudentT("sd_def", nu=3, sigma=2.5)
intercept = pm.Flat("intercept")
# team-specific model parameters
atts_star = pm.Normal("atts_star", mu=0, sigma=sd_att, shape=num_teams)
defs_star = pm.Normal("defs_star", mu=0, sigma=sd_def, shape=num_teams)
atts = pm.Deterministic("atts", atts_star - tt.mean(atts_star))
defs = pm.Deterministic("defs", defs_star - tt.mean(defs_star))
home_theta = tt.exp(intercept + home + atts[home_team] + defs[away_team])
away_theta = tt.exp(intercept + atts[away_team] + defs[home_team])
# likelihood of observed data
home_points = pm.Poisson("home_points", mu=home_theta, observed=observed_home_goals)
away_points = pm.Poisson("away_points", mu=away_theta, observed=observed_away_goals)
and here is the error I’m getting: