Compute posterior quadrature weights for a 2PL model
Source:R/quadrature.R
posterior_weights_2pl.RdComputes each subject's posterior distribution over a fixed quadrature grid
under a 2PL model, using stable log-likelihood calculations. Fractional
responses in [0, 1] are allowed at this low level, which is useful when LLM
output is stored as probabilities rather than sampled binary responses.
Arguments
- resp
A response matrix with rows for subjects and columns for items. Values may be binary, fractional in
[0, 1], orNA.- item_pars
Item parameters in slope-intercept form. Supply a data frame or matrix with columns
a/a1andd, or a fittedmirtmodel.- quadrature
Optional quadrature data frame with
thetaandweightcolumns. If omitted, a standard-normal grid is created.- n_quad
Number of quadrature nodes used when
quadratureis omitted.- iterlim
Maximum number of Newton-Raphson iterations passed to
rmutil::gauss.hermite()whenquadratureis omitted.
Value
A matrix with one row per subject and one column per quadrature node.
Rows sum to one. Attributes theta and weight contain the grid.
Details
Note: the high-level mixed-subjects fitting functions
(fit_mixed_subjects_mml() and relatives) require binary predicted and
generated; fractional input is supported only in these low-level quadrature
utilities. If you have LLM-derived probabilities, sample binary responses from
them (e.g. with stats::rbinom()) before calibrating.