sample_gtum#
- pyfcirt.sample_gtum(
- model,
- *,
- draws=1000,
- tune=1000,
- chains=4,
- random_seed=None,
- var_names=None,
- target_accept=0.8,
- max_treedepth=10,
- initial_step_size=1.0,
- dense_mass=False,
- initvals=None,
- progressbar=False,
- compute_convergence_checks=True,
- overwrite=False,
Fit a logistic GTUM model with the experimental NUTS and conditional MH sampler.
Parameters#
model: ModelPrepared model with ordinary logistic GTUM only, centered traits, and no population groups or covariates. Use the original native graph.
draws,tune,chains: intRetained draws and warmup iterations per chain, and number of chains. Defaults: 1000, 1000 and 4.
random_seed: int or NoneSampling seed.
var_names: sequence of str or NoneNative final variables to retain. Explicit selections must include
thetaand required free final measurement and population parameters.target_accept: floatTarget NUTS acceptance. Default: 0.8.
max_treedepth: intMaximum tree depth. Default: 10.
initial_step_size: floatInitial step size. Default: 1.0.
dense_mass: boolUse a dense mass matrix. Default:
False.initvals: mapping, sequence of mappings or NoneInitial values, shared or supplied one mapping per chain.
progressbar: boolThis sampler requires
False(the default).compute_convergence_checks: boolRun native convergence checks. Default:
True.overwrite: boolReplace an existing fit. Default:
False.
Returns#
- xarray.DataTree
posteriorcontainstheta(chain, draw, person, trait)and the retained calibration variables.sample_statsincludes NUTS and conditional proposal diagnostics. The result becomesmodel.idata.
Notes#
The experimental sampler requires BlackJAX and float64. Warmup uses full-parameter NUTS. Each retained transition includes a conditional Metropolis–Hastings update for person traits. Examine rank diagnostics, NUTS divergences and conditional proposal diagnostics after fitting.
Examples#
Fit the logistic GTUM model with this call:
import pyfcirt as fc
example = fc.load_example("simulated_gtum", model="GTUM", n_persons=50)
model = fc.Model(example.data)
idata = fc.sample_gtum(model, draws=1000, tune=1000, chains=4, random_seed=43)
Check an unsupported model#
import pyfcirt as fc
example = fc.load_example("tirt_study", model="TIRT", n_persons=3)
model = fc.Model(example.data)
try:
fc.sample_gtum(model)
except ValueError as error:
print(error)
Conditional MH requires original logistic GTUM measurements only
See also#
GTUM and standard NUTS.