Predictions for specific values when using model averaging


After averaging three models (see example, I am generating predictions using this code:

ppc_w = pm.sample_ppc_w(traces, 1000, models,

I would like to create counterfactual predictions based on specific values (data), but there is no data argument in the sample_ppc_w function.

Any ideas or suggestions on how to do it??

If you are trying to generate prediction conditioned on some specific input/data, you should set your input as theano.shared variable, and set the new value for prediction before you do pm.sample_ppc_w or pm.sample_ppc. There is an example here:

1 Like

Cool, thanks!

Hi junpenglao,

Could you say it clearly? To me, the sample_ppc_w would require different data inputs, how could we build our shared variables to fit the prediction?

sample_ppc_w works similar to sample_ppc, the only difference is in sample_ppc_w you input multiple model and trace. So your workflow would be:

  1. setting up theano shared variable
  2. use said shared variable to build and sample multiple model
  3. set the value of shared variable to the new test data
  4. run sample_ppc_w
1 Like

The link is down

Check here and here. The notebooks were split up a while back and broke the old links.

Thanks @cluhmann

It seems that the latter link has been changed to posterior_predictive.html