Hierarchical Model - Input Dimension Mis-Match on New Data

This happens for me when I forget to include one of the inputs variables in the new data, so the model sees two different shapes: the shape of the new data and the shape of the old input that’s missing in the new data. If that makes sense :stuck_out_tongue:

You need to supply a value for all of these:

income = pm.Data('income', df.Pct_Over_National_Average.values) consumer = pm.Data('consumer', df.Idx_Consumer_Sentiment.values)
urban = pm.Data('urban', df.urban_pct.values)
density = pm.Data('density', df.pop_density.values)
nonHS = pm.Data('nonHS', df.nonHS_graduate.values)
pct_asian = pm.Data('pct_asian', df.pct_asian.values)
adv_degree = pm.Data('adv_degree', df.advanced_degree_or_more.values)
approval = pm.Data('approval', df.Y4_avg_net_approval.values)
evang = pm.Data('evang', df.evangelical_pct.values)

I suspect that you also need to change this:

Y_obs = pm.Bernoulli('Y_obs', theta, observed=df['dem_state_win'].values)

To this and supply a value for it:

dm_state_win = pm.Data('dm_state_win ', df['dem_state_win'].values)
Y_obs = pm.Bernoulli('Y_obs', theta, observed=dm_state_win)