GPCMDistribution#

class pyfcirt.models.likert.GPCMDistribution(
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 GPCMDistribution.dist(theta, loading, category_intercept, *, size=None, shape=None)#

Generalized partial credit response distribution for one item.

Parameters#

theta

Ability values along the final trait axis.

loading

Loadings aligned with the final axes of theta.

category_intercept

One intercept per category on the final axis; the first is zero.

size

Native PyMC batch size. Choose either size or shape.

shape

Output 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.

Notes#

The caller supplies identification and any prior distributions.

Examples#

Evaluate a response#

The example specifies three ordered categories with separate intercepts. The output is the log probability of category index 1.

import pymc as pm
from pyfcirt.models.dist import GPCMDistribution

rv = GPCMDistribution.dist([0.2], [1.2], [0.0, 0.4, -0.2])
print(round(float(pm.logp(rv, 1).eval(mode="JAX")), 6))
-0.799743

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 = GPCMDistribution("response", [0.2], [1.2], [0.0, 0.4, -0.2], observed=1)
print([rv.name for rv in custom.observed_RVs])
['response']

See also#

Native distributions and measurement declarations.