Hi, I was hoping for some help figuring out why this model is so slow. It only samples ~2 per second, so it takes a very long time to generate anything useful.
Here is the code. There are 30 teams each with an index in the dataset and the values of the observations are interger valued. This is supposed to be a state space model, which is why the latent variable is modeled as an AR1 (though bc. it’s multivariate I had to use AR rather than AR1).
with pm.Model() as fg3m_AR:
comb_off_coef = pm.Normal('comb_off_coef',mu = 1, sigma = 20, shape = (1,30) )
comb_def_coef = pm.Normal('comb_def_coef',mu = 1, sigma = 20, shape = (1,30))
comb_off_ar1 = pm.Bound(pm.AR,lower = 0.0)('comb_off_ar1',rho = comb_off_coef, sigma = 10, shape = (81,30))
comb_def_ar1 = pm.Bound(pm.AR,lower = 0.0)('comb_def_ar1',rho = comb_def_coef, sigma = 10, shape = (81,30))
comb_sd_star = pm.Gamma("comb_sd_star", alpha = 1/3,beta = 1/9, shape = 30)
home_theta = pm.Deterministic('home_theta',comb_off_ar1[fg3m.GAME_NUMBER_x.values,fg3m.i_home.values]
+ comb_def_ar1[fg3m.GAME_NUMBER_y.values,fg3m.i_away.values])
away_theta = pm.Deterministic('away theta',comb_off_ar1[fg3m.GAME_NUMBER_y.values,fg3m.i_away.values]
+ comb_def_ar1[fg3m.GAME_NUMBER_x.values,fg3m.i_home.values]
y_home = pm.Normal('y_home',mu = home_theta, sd = comb_sd_star[fg3m.i_home.values] , observed = fg3m.FG3M_x.values)
y_away = pm.Normal('y_away',mu = away_theta, sd = comb_sd_star[fg3m.i_away.values], observed = fg3m.FG3M_y.values)