posterior_predictive#
- pyfcirt.posterior_predictive(
- model: Model,
- *,
- draws=None,
- random_seed=None,
- include_probabilities=True,
- store=True,
- progressbar=True,
Generate responses at fitted posterior states.
Parameters#
model: ModelFitted model with MCMC draws and final parameters used by the response law.
draws: int or NoneNumber of joint posterior states to use.
Nonekeeps all states in their original chains; an explicit count selects states into one predictive chain.random_seed: int or NoneSeed for state selection and simulated responses.
include_probabilities: boolAlso return probabilities or Beta parameters. Default:
True.store: boolKeep the returned groups in
model.idata. Default:True.progressbar: boolDisplay progress. Default:
True.
Returns#
- xarray.DataTree
posterior_predictivecontains replicated responses overchain,drawand native observation axes.response_probabilitiesadds one category axis per categorical batch; Beta batches provide parameters inresponse_parameters. Usepredictive_view()to align one unit with its observed answers.
Examples#
Use a fitted Model. The output below comes from the HEXACO TIRT example.
Generate 24 replicates, then check the draw and observation counts for block B1.
import pyfcirt as fc
predictions = model.posterior_predictive(
draws=24,
random_seed=45,
store=False,
progressbar=False,
)
view = fc.predictive_view(predictions, block="B1")
print(dict(view.posterior_predictive.response.sizes))
{'chain': 1, 'draw': 24, 'obs': 360}