Model.posterior_approximation#
- Model.posterior_approximation(
- *,
- var_names=None,
- joint: bool | None = None,
- method='auto',
- components=(2, 3),
- random_seed=None,
- transforms=None,
Fit a runtime calibration prior from labelled posterior draws for experimental posterior scoring and recursive calibration.
Parameters#
var_names: sequence of str, mapping or NoneShared native PyMC RV names. A mapping gives explicit groups by parameter kind. On the first round,
Noneselects all supported free shared RVs and pools them into one group by default. On later rounds,Nonereuses the incoming approximation’s selection. An explicit selection updates only the supplied RVs.joint: bool or NoneDefault:
Noneselects one group namedjointon the first round with automatic selection. It keeps the grouping for explicitvar_namesor an incoming approximation. UseFalseto start with separate groups by kind. UseTrueto pool the automatic selection, including inherited members. Supply eitherjoint=Trueor explicitvar_names. Full-covariance fits require more retained draws than the joint dimension.method: strDefault:
"auto"selects one full-covariance Gaussian or a mixture per group. See the approximation methods.components: sequence of intCandidate mixture sizes. Default:
(2, 3).random_seed: int or NoneSeed for fitting the approximation.
transforms: mapping or NoneNative transform overrides keyed by RV name.
Noneuses native defaults or inherits the previous round’s overrides.{}restores native defaults on a later round.
Returns#
- PosteriorApproximation
A runtime prior for the selected shared variables and a record of covered calibration data. Supply it to
score_model(calibration="posterior", approximation=prior).
Notes#
Use Model.fit(retain_calibration=True) to retain the native draws for
an initial PyFCIRT calibration. The posterior must also include any RVs
needed by the selected parameters’ transforms. A 4PL upper asymptote, for example, can need paired draws of
its lower asymptote. Use shared calibration variables; respondent traits are
estimated afresh in the scored model.
Examples#
Use the fitted MGPPM model from the recursive scoring example.
By default, the approximation pools the loadings, intercepts and trait
correlations into one group and selects the density family with auto.
prior = calibration.posterior_approximation(random_seed=45)
print(tuple(prior.groups), len(prior.evidence_people))
scoring = calibration.score_model(
batches[0],
calibration="posterior",
approximation=prior,
)
('joint',) 50