2.2.1 Predict weight (in pounds) from height (in inches)
new = pd.DataFrame(dict(height=[66]))pred = model_1.predict(idata_1, data=new, kind="pps", inplace=False)pred_mean = pred.posterior_predictive["weight"].values.mean()pred_sd = pred.posterior_predictive["weight"].values.std()print(f"Predicted weight for a 66-inch-tall person is {round(pred_mean)} pounds with a sd of {round(pred_sd)}")
Predicted weight for a 66-inch-tall person is 153 pounds with a sd of 29
new = pd.DataFrame(dict(c_height=[4], male=[0]))pred = model_3.predict(idata_3, data=new, kind="pps", inplace=False)pred_mean = pred.posterior_predictive["weight"].values.mean()pred_sd = pred.posterior_predictive["weight"].values.std()print(f"Predicted weight for a 70-inch-tall female is {round(pred_mean)} pounds with a sd of {round(pred_sd)}")
Predicted weight for a 70-inch-tall female is 165 pounds with a sd of 29
2.2.3 Using indicator variables for multiple levels of a categorical predictor