How to properly do out-of-sample prediction for hierarchical model

temp_df2 = testing_data_lite
idx2 = temp_df2.race_idx

Doesn’t look like you are using idx2 in the prediction model but still idx. Certainly you are doing some indexing error that has nothing to do with sample_posterior_predictive