HEXACO scores with the generalized partial preference model#

Fit MGPPM to observed best–worst choices from HEXACO triplets and check whether the model reproduces their relative frequencies.

Model the ranking patterns#

Let \(p\) index respondents, \(b\) index blocks and \(j\) index statements. The trait measured by statement \(j\) is \(t(j)\). Its utility for respondent \(p\) is

\[u_{pj}=q_j a_j\theta_{p,t(j)}-b_j,\]

where \(\theta_{p,t(j)}\) is the trait score, \(a_j>0\) is the loading magnitude, and \(q_j\in\{-1,+1\}\) is the keying sign. A larger statement intercept \(b_j\) lowers its utility.

For a complete order \(r\) in a block with \(K\) statements, let \(s_{rj}\) be \(K\) minus the rank of statement \(j\). The highest rank is 1. The utility \(\eta_{pbr}\) of the entire order is the sum of the scored utilities:

\[\eta_{pbr}=\sum_{j\in b}s_{rj}u_{pj}.\]

In the order \(A>B>C\), the scores of \(A,B,C\) are \(2,1,0\), so \(\eta_{pbr}=2u_{pA}+u_{pB}\). For \(A>C>B\), it is \(2u_{pA}+u_{pC}\). The observed block response \(Y_{pb}\) has probability

\[P(Y_{pb}=r) =\frac{\exp(\eta_{pbr})} {\sum_{r'\in\mathcal R_b}\exp(\eta_{pbr'})},\]

where \(\mathcal R_b\) contains all possible complete orders for the block, including orders absent from the sample. A triplet has six terms in the denominator. When the response specifies only part of an order, sum the probabilities of the compatible orders. Furr and Fu (2025)

Set the score scale#

Each trait has mean zero and SD one. All complete orders of a triplet have the same total score, so a common utility shift cancels in the probability. A zero reference intercept sets the origin. Keying sets the direction of each loading. MGPPM model and priors

import seaborn as sns

import pyfcirt as fc

sns.set_theme(style="ticks")

Read the questionnaire and responses#

The bundled FC3 data contain 200 respondents and 20 HEXACO triplets from Li et al. (2025). The design names each statement, its position, trait and keying. Each answer records the most- and least-preferred positions. With three statements, those two positions determine the full order.

example = fc.load_example("hexaco_fc3", model="MGPPM")
design = example.data.design
responses = example.data.responses.frame
design.head(3)
block_id position statement_id trait keying
0 B1 1 i1 honestyhumility -1
1 B1 2 i2 openness -1
2 B1 3 i3 agreeableness -1

A row with [3, None, 1] records statement 3 as best and statement 1 as worst. Statement 2 is the middle choice.

responses.head(3)
person_id block_id response
0 1 B1 [3, None, 1]
1 1 B2 [3, None, 2]
2 1 B3 [1, None, 2]
model = fc.Model()
model.add_fc(
    design,
    responses,
    format="block_long",
    response_format="mole",
    model="MGPPM",
)
model.prepare()
print(model.summary())
Model: MGPPM
200 people, 6 traits, 20 blocks, 60 statements
Observations: 4,000 block events
Measurements:
  mole: 20 blocks, size=3, categories=6
Population:
  theta ~ MvNormal(mu=0, cov=R)
  R [6 x 6] ~ LKJCorr(n=6, eta=1)
Priors:
    loading [60] ~ LogNormal(mu=0, sigma=0.5)
    statement_intercept [40] ~ Normal(mu=0, sigma=2)
Constraints:
    statement_intercept: fixed=0 [20 fixed]

The summary counts whole-block best–worst events and lists the reference statement intercepts.

Fit the model#

Each person–block answer contributes one category probability.

model.fit(draws=1200, tune=1800, chains=4);

Diagnose the chains#

Check that the chains agree before using the posterior estimates.

import arviz as az
import numpy as np

posterior = model.idata.posterior.to_dataset().reset_coords(drop=True)
with np.errstate(invalid="ignore", divide="ignore"):
    r_hat = az.rhat(posterior).max().to_array().max().item()
    bulk = az.ess(posterior, method="bulk").min().to_array().min().item()
    tail = az.ess(posterior, method="tail").min().to_array().min().item()

print(f"Max R-hat: {r_hat:.3f}")
print(f"Min bulk / tail ESS: {bulk:.0f} / {tail:.0f}")
print("Divergences:", int(model.idata.sample_stats.diverging.sum()))
Max R-hat: 1.007
Min bulk / tail ESS: 779 / 1229
Divergences: 0

The rank and density panels inspect one respondent’s Honesty–Humility score.

Hide code cell source

import arviz_plots as azp
import matplotlib.pyplot as plt

azp.plot_rank_dist(
    model.idata,
    var_names=["theta"],
    coords={
        "person": [model.idata.posterior.person.values[0]],
        "trait": ["honestyhumility"],
    },
    backend="matplotlib",
    compact=False,
    figure_kwargs={"figsize": (7, 3), "layout": "constrained"},
)
plt.show()
../_images/894e381876ffda7c4c1c97726fd954ee562f993e4b5a294d020b4e1a0b6b4289.png

Read the statement parameters#

Read the loadings and intercepts of the three statements in B1.

model.coef(blocks=["B1"], kind="stats", round_to=2)
mean sd hdi95_lb hdi95_ub
unit statement trait parameter
B1 i1 honestyhumility loading 1.37 0.27 0.87 1.89
i2 openness loading 0.55 0.14 0.29 0.83
i3 agreeableness loading 0.46 0.13 0.22 0.72
i1 honestyhumility statement_intercept 0.00 NaN NaN NaN
i2 openness statement_intercept -0.90 0.18 -1.27 -0.56
i3 agreeableness statement_intercept -1.43 0.20 -1.83 -1.04

Check the predicted rankings#

Compare the observed proportions with 200 sets of replicated responses in block B1. A cross marks an observed proportion. A point and line show a predictive mean and 95% interval.

predictions = model.posterior_predictive(draws=200, random_seed=45)
view = fc.predictive_view(predictions, block="B1")

Hide code cell source

from itertools import permutations

import pandas as pd
import xarray as xr

statements = design.query("block_id == 'B1'").sort_values("position").statement_id
labels = [f"{best} / {worst}" for best, worst in permutations(statements, 2)]
category = xr.DataArray(range(len(labels)), dims="pair", coords={"pair": labels})


def proportions(answers, sample):
    share = (answers == category).mean("obs")
    return share.to_dataframe(name="Proportion").reset_index().assign(Sample=sample)


results = pd.concat(
    [
        proportions(view.posterior_predictive.response, "Replicated"),
        proportions(view.observed_data.response, "Observed"),
    ]
)
fig, ax = plt.subplots(figsize=(6, 3.4), layout="constrained")
sns.pointplot(
    data=results,
    x="Proportion",
    y="pair",
    hue="Sample",
    order=labels,
    markers=["o", "x"],
    linestyles="none",
    errorbar=("pi", 95),
    ax=ax,
)
ax.set(ylabel="Best / worst statement")
plt.show()
../_images/cd3d8f23506da2305c805f32a3cb27ee9b43bdb7c4d558a6ad928e711760d9f1.png

The most common B1 response names i3 as best and i1 as worst. It accounts for 48.5% of the observed answers.

Check overall fit#

The Pearson check pools the discrepancies across the 20 triplets.

Hide code cell source

overall = model.chi_ppp(predictions=predictions)
fc.plot_ppp(overall, quantile_range=(0.005, 0.995), figsize=(6, 3))
plt.show()
../_images/ce947699c684fc611e649116fa2bf6debd792daa3f1ee1caecba4d75f90065d5.png

Read score precision#

Empirical reliability compares score variation with posterior uncertainty.

model.reliability()["reliability"].to_series().round(3).to_frame("Reliability")
Reliability
trait
honestyhumility 0.692
openness 0.597
agreeableness 0.523
emotionality 0.563
conscientiousness 0.554
extraversion 0.704

A ridge plot shows the uncertainty in the Honesty–Humility and Openness scores for three respondents.

Hide code cell source

fc.plot_ridge(
    model.idata,
    coords={"person": [1, 2, 3], "trait": ["honestyhumility", "openness"]},
    max_rows=3,
    col_wrap=2,
    figsize=(8, 3),
)
plt.show()
../_images/68e0bbdf02c7130a2cadbddb997c78f2fd39a628681f16976520dd3e44480979.png

See 2PLM-RANK for a successive-choice model fitted to the same responses.