GTUMDistribution#
- class pyfcirt.models.thurstonian.gtum.GTUMDistribution(
- name: str,
- *args,
- rng=None,
- dims: str | Sequence[str | None] | None = None,
- initval=None,
- observed=None,
- total_size=None,
- transform=UNSET,
- default_transform=UNSET,
- **kwargs,
- classmethod GTUMDistribution.dist(
- theta,
- loading,
- location,
- cutpoints,
- *,
- link='logit',
- person_block_effect=0.0,
- precision=None,
- direction=1,
- size=None,
- shape=None,
Unfolding response distribution for a recorded pair.
Parameters#
thetaTrait values at the two recorded statement positions, final shape (ā¦, 2).
loadingPositive loading magnitudes for the two statements.
locationSigned ideal-point locations aligned with
thetaandloading.cutpointsCategorical boundaries in increasing order on a final Cā1 axis for C categories. For Beta, give one offset per observation.
linklogit(default) orbeta_logit; neither uses a residual scale or link multiplier.person_block_effectScalar or observation-aligned effect for the discrete model. Default: 0.
precisionPositive Beta concentration. Supply it for a Beta link.
direction+1 (default) makes higher values favor the first recorded statement; ā1 favors the second.
sizeNative PyMC batch size. Choose either
sizeorshape.shapeOutput shape, alternative to
size. Parameter axes must be known.
For the named form, also supply name and optional PyMC arguments including
observed and dims. Parameter lengths must be known; a dims label
does not infer the shape of a symbolic parameter.
Returns#
- TensorVariable
An unnamed PyMC response RV from
.dist(). The named constructor registers the response in the model. When evaluating or supplying responses, category indices start at 0; use the actual rating when the link is Beta.
Notes#
The block effect enters the discrete utility difference before applying direction. Use zero for Beta.
Examples#
Evaluate a response#
Positive loading magnitudes and actual signed locations follow the recorded order. The output is the log probability of category index 1.
import pymc as pm
from pyfcirt.models.dist import GTUMDistribution
rv = GTUMDistribution.dist([0.2, -0.4], [1.0, 1.2], [1.0, -1.0], [0.0])
print(round(float(pm.logp(rv, 1).eval(mode="JAX")), 6))
-0.733947
Register an observed response#
Use the same arrays inside a native PyMC model. The observed variable is registered under its name.
with pm.Model() as custom:
response = GTUMDistribution("response", [0.2, -0.4], [1.0, 1.2], [1.0, -1.0], [0.0], observed=1)
print([rv.name for rv in custom.observed_RVs])
['response']
Continuous ratings#
Evaluate a Beta log density at a rating of 0.7 with precision 20.
response = GTUMDistribution.dist(
[0.2, -0.4], [1.0, 1.2], [1.0, -1.0], 0.0, link="beta_logit", precision=20.0
)
print(round(float(pm.logp(response, 0.7).eval(mode="JAX")), 6))
-0.665153
Ordered categories#
Two increasing cutpoints produce three categories. This evaluates the middle category.
response = GTUMDistribution.dist([0.2, -0.4], [1.0, 1.2], [1.0, -1.0], [-0.5, 0.5])
print(round(float(pm.logp(response, 1).eval(mode="JAX")), 6))
-1.408333