Skip to content

GMeasurement · measurement.facets

Many-facet Rasch model (rater severity)

How severe is each rater, how able is each person and how hard is each task, all on one scale?

Linacre's many-facet Rasch model for ordered ratings, one row per rating (person, rater, optional task or item, score). Each score is explained by the person's ability minus the rater's severity minus the task's difficulty, through Rasch–Andrich thresholds shared by all ratings, or one set per task or per rater. Fitted by joint maximum likelihood, as in the Facets program. Reports every element's measure in logits with its standard error and infit/outfit mean squares, separation and reliability for each facet, the fixed chi-square test that all raters are equally severe, and a Wright map that puts persons, raters, tasks and thresholds on one ruler.

Verified in Python and R Python and R agree to 6 decimals

A real result

Example “Essays shared”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Many-facet Rasch modelRecorded · Python and R agreeRecorded 2026-11-21 · 53 values compared
R

Many-facet Rasch model (JML): rater fixed χ²(3) = 16.42, p < .001; rater separation reliability = .75

Rater fixed χ²
16.418
p
< .001
Rater separation reliability
0.7510

Plots

Wright map: persons, raters, items and thresholds on one logit scaleWhere do persons, raters, tasks and score steps sit on one measurement scale?
View data
FacetElementMeasure (logits)
Personse012.233
Personse020.5065
Personse030.7616
Personse041.380
Personse050.1244
Personse06−0.8463
Personse070.7712
Personse08−2.327
Personse090.9109
Personse10−0.2382
Personse11−3.857
Personse12−0.9394
Personse13−0.4770
Personse140.5065
Personse15−0.3835
Personse160.0301
Personse170.3400
Personse18−0.2906
Personse19−1.368
Personse20−0.2906
Personse211.139
Personse22−3.345
Personse231.144
Personse24−1.977
Personse250.6468
Personse261.596
Personse270.9734
Personse281.139
Personse29−2.409
Personse301.277
Personse311.486
Personse32−0.8463
Personse33−0.4386
Personse341.093
Personse35−2.018
Personse361.892
Personse37−0.2382
Personse382.924
Personse390.1041
Personse401.641
Ratersr1−0.5429
Ratersr20.2134
Ratersr30.0316
Ratersr40.2979
Itemsargument−0.4775
Itemsevidence0.1389
Itemsstyle0.3386
Thresholds2−2.259
Thresholds3−0.3407
Thresholds40.8937
Thresholds51.706
Rater severity (±1.96 SE)How large are several estimates, how precise, and which exclude the null?
View data
Severity (logits)HighRaterLow
−0.5429−0.2262r1−0.8596
0.21340.5444r2−0.1177
0.03160.3541r3−0.2908
0.29790.6102r4−0.0143
Category probability curvesHow does the probability of each response change with the latent trait, item by item?
View data
ScoreScaleProbabilityMeasure relative to the rating (logits)
1Scale0.9767−6
1Scale0.9744−5.900
1Scale0.9717−5.800
1Scale0.9688−5.700
1Scale0.9656−5.600
1Scale0.9621−5.500
1Scale0.9583−5.400
1Scale0.9541−5.300
1Scale0.9495−5.200
1Scale0.9444−5.100
1Scale0.9389−5
1Scale0.9328−4.900
1Scale0.9262−4.800
1Scale0.9190−4.700
1Scale0.9111−4.600
1Scale0.9025−4.500
1Scale0.8932−4.400
1Scale0.8831−4.300
1Scale0.8722−4.200
1Scale0.8603−4.100
1Scale0.8476−4
1Scale0.8338−3.900
1Scale0.8190−3.800
1Scale0.8032−3.700
1Scale0.7863−3.600
1Scale0.7684−3.500
1Scale0.7493−3.400
1Scale0.7291−3.300
1Scale0.7078−3.200
1Scale0.6854−3.100
1Scale0.6620−3
1Scale0.6376−2.900
1Scale0.6123−2.800
1Scale0.5862−2.700
1Scale0.5594−2.600
1Scale0.5321−2.500
1Scale0.5042−2.400
1Scale0.4761−2.300
1Scale0.4477−2.200
1Scale0.4194−2.100
1Scale0.3913−2
1Scale0.3634−1.900
1Scale0.3361−1.800
1Scale0.3094−1.700
1Scale0.2834−1.600
1Scale0.2584−1.500
1Scale0.2345−1.400
1Scale0.2116−1.300
1Scale0.1900−1.200
1Scale0.1697−1.100
1Scale0.1507−1
1Scale0.1331−0.9000
1Scale0.1168−0.8000
1Scale0.1020−0.7000
1Scale0.0884−0.6000
1Scale0.0762−0.5000
1Scale0.0653−0.4000
1Scale0.0555−0.3000
1Scale0.0469−0.2000
1Scale0.0393−0.1000

First 60 of 605 rows.

Assumptions

  • Rater fit — Every rater's infit and outfit mean squares are within 0.5–1.5.
  • Unexpected ratings — 4.6% of ratings have |z| > 2 and 0.0% have |z| > 3 (about 5% and 1% expected).
  • Category use — Every score category has at least 10 ratings.
  • Extreme scores — 1 person(s) with the lowest or highest score in every rating were set aside (no finite estimate).
  • Convergence — Newton–Raphson converged after 8 iterations.

Raters (higher = more severe)

RaterMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
r1−0.54290.16160.83210.8419602.483
r20.21340.16891.0371.087601.783
r30.03160.16450.80570.8129601.983
r40.29790.15931.2721.273601.850

Items (higher = harder)

ItemMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
argument−0.47750.14201.2701.218802.325
evidence0.13890.14090.94270.9913801.938
style0.33860.14180.75730.8018801.813

Persons (higher = more able)

PersonMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
e012.2330.62520.31940.359963.500
e020.50650.46360.30790.308162.167
e030.76160.46050.40570.409662.333
e041.3800.49941.0030.908563
e050.12440.46610.27930.273762.167
e06−0.84630.54720.80160.840561.167
e070.77120.46830.69210.672962.667
e08−2.3270.69800.76060.777060.5000
e090.91090.47310.40970.428962.667
e10−0.23820.48300.60330.595461.833
e11−3.8571.0691.0581.23860.1667
e12−0.93940.54730.96040.990961.167
e13−0.47700.49481.7341.72461.667
e140.50650.46361.1011.09462.167
e15−0.38350.50872.1452.03461.500
e160.03010.47490.45410.444862
e170.34000.46311.3191.31862.333
e18−0.29060.50861.2771.33161.500
e19−1.3680.54741.0620.945961.167
e20−0.29060.50862.7652.57961.500
e211.1390.48310.76600.749262.833
e22−3.3450.81170.83231.09460.3333
e231.1440.46451.0431.05062.667
e24−1.9770.63920.74810.725960.6667
e250.64680.46641.8291.86462.500
e261.5960.48980.58470.602363
e270.97340.46070.38590.384062.500
e281.1390.48311.5611.70362.833
e29−2.4090.64101.2441.23660.6667
e301.2770.46420.96940.984462.667
e311.4860.51930.67470.749563.167
e32−0.84630.54720.83350.869461.167
e33−0.43860.49521.8271.86961.667
e341.0930.48130.84600.853962.833
e35−2.0180.63901.6911.64960.6667
e361.8920.51560.90650.889063.167
e37−0.23820.48301.3971.33261.833
e382.9240.73570.80630.894363.667
e390.10410.48050.72600.711261.833
e401.6410.52460.61070.670563.167

First 40 of 41 rows.

Rasch–Andrich thresholds

ScaleStep up to scoreThreshold (logits)
Scale2−2.259
Scale3−0.3407
Scale40.8937
Scale51.706

Separation and reliability

FacetSD of measuresRMSESeparationReliabilityFixed χ² (all same)dfp
Persons1.4780.55252.4810.8603207.1139< .001
Raters0.32790.16361.7370.751016.4183< .001
Items0.34730.14162.2410.833917.9842< .001
  • Joint maximum likelihood (as in Facets): rater severities and item difficulties centered at 0, thresholds centered within each scale; local model SEs (1/√information). JML measures are slightly spread out when an element has few ratings.
Python

Many-facet Rasch model (JML): rater fixed χ²(3) = 16.42, p < .001; rater separation reliability = .75

Rater fixed χ²
16.418
p
< .001
Rater separation reliability
0.7510

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Rater fit — Every rater's infit and outfit mean squares are within 0.5–1.5.
  • Unexpected ratings — 4.6% of ratings have |z| > 2 and 0.0% have |z| > 3 (about 5% and 1% expected).
  • Category use — Every score category has at least 10 ratings.
  • Extreme scores — 1 person(s) with the lowest or highest score in every rating were set aside (no finite estimate).
  • Convergence — Newton–Raphson converged after 8 iterations.

Raters (higher = more severe)

RaterMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
r1−0.54290.16160.83210.8419602.483
r20.21340.16891.0371.087601.783
r30.03160.16450.80570.8129601.983
r40.29790.15931.2721.273601.850

Items (higher = harder)

ItemMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
argument−0.47750.14201.2701.218802.325
evidence0.13890.14090.94270.9913801.938
style0.33860.14180.75730.8018801.813

Persons (higher = more able)

PersonMeasure (logits)SEInfit MnSqOutfit MnSqRatingsMean score (category)Extreme
e012.2330.62520.31940.359963.500
e020.50650.46360.30790.308162.167
e030.76160.46050.40570.409662.333
e041.3800.49941.0030.908563
e050.12440.46610.27930.273762.167
e06−0.84630.54720.80160.840561.167
e070.77120.46830.69210.672962.667
e08−2.3270.69800.76060.777060.5000
e090.91090.47310.40970.428962.667
e10−0.23820.48300.60330.595461.833
e11−3.8571.0691.0581.23860.1667
e12−0.93940.54730.96040.990961.167
e13−0.47700.49481.7341.72461.667
e140.50650.46361.1011.09462.167
e15−0.38350.50872.1452.03461.500
e160.03010.47490.45410.444862
e170.34000.46311.3191.31862.333
e18−0.29060.50861.2771.33161.500
e19−1.3680.54741.0620.945961.167
e20−0.29060.50862.7652.57961.500
e211.1390.48310.76600.749262.833
e22−3.3450.81170.83231.09460.3333
e231.1440.46451.0431.05062.667
e24−1.9770.63920.74810.725960.6667
e250.64680.46641.8291.86462.500
e261.5960.48980.58470.602363
e270.97340.46070.38590.384062.500
e281.1390.48311.5611.70362.833
e29−2.4090.64101.2441.23660.6667
e301.2770.46420.96940.984462.667
e311.4860.51930.67470.749563.167
e32−0.84630.54720.83350.869461.167
e33−0.43860.49521.8271.86961.667
e341.0930.48130.84600.853962.833
e35−2.0180.63901.6911.64960.6667
e361.8920.51560.90650.889063.167
e37−0.23820.48301.3971.33261.833
e382.9240.73570.80630.894363.667
e390.10410.48050.72600.711261.833
e401.6410.52460.61070.670563.167

First 40 of 41 rows.

Rasch–Andrich thresholds

ScaleStep up to scoreThreshold (logits)
Scale2−2.259
Scale3−0.3407
Scale40.8937
Scale51.706

Separation and reliability

FacetSD of measuresRMSESeparationReliabilityFixed χ² (all same)dfp
Persons1.4780.55252.4810.8603207.1139< .001
Raters0.32790.16361.7370.751016.4183< .001
Items0.34730.14162.2410.833917.9842< .001
  • Joint maximum likelihood (as in Facets): rater severities and item difficulties centered at 0, thresholds centered within each scale; local model SEs (1/√information). JML measures are slightly spread out when an element has few ratings.

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Essays sharedfacets_sim · item: task · person: essay · rater: rater · score: score
  • Essays by raterfacets_sim · item: task · person: essay · rater: rater · score: score
  • Essays by task gradesfacets_sim · item: task · person: essay · rater: rater · score: grade
  • Essays two facetsfacets_sim · person: essay · rater: rater · score: score
  • Degenerate constantfacets_sim · item: task · person: essay · rater: rater · score: score
  • Degenerate single levelfacets_sim · item: task · person: essay · rater: rater · score: score
  • Degenerate n1facets_sim · item: task · person: essay · rater: rater · score: score
  • Degenerate inffacets_sim · item: task · person: essay · rater: rater · score: score

In the guides

Where it sits in the decision guides

  • Rater severity on one scale: many-facet Rasch · Statistics Guide · G — Agreement / reliability

What you need

Person (or performance)categorical · 1 column · 2–2000 levels
Who or what is being measured — an examinee, an essay, a system's answer. Each needs ratings from at least one rater.
Ratercategorical · 1 column · 2–200 levels
Who gave the score (a judge, a marker or an AI judge). Raters must be linked through shared persons for their severities to be comparable.
Task or item (optional)categorical · 0–1 column · 2–200 levels
A third facet, such as the task, criterion or prompt that was scored. Leave empty when every rating is of the same thing.
Scorenumeric / categorical · 1 column
The ordered rating — whole numbers (1–5) or categories in their stored order (poor < fair < good). At most 15 categories.

Choices you make

model

Rating scaledefault shared

Shared thresholds need the fewest ratings; a scale per task or rater needs every score category used within each task or rater.

  • One scale for every rating (rating-scale model)(default) — Every rater and task uses the score categories the same way; the usual choice.
  • One scale per task (partial credit) — Each task has its own thresholds, for tasks whose score steps mean different things.
  • One scale per rater — Each rater has their own thresholds, to see raters who avoid the extreme categories or bunch in the middle.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Rater fit

    Infit and outfit mean squares between 0.5 and 1.5 are productive for measurement (Linacre); above 1.5 a rater is erratic, below 0.5 too predictable.

  • Unexpected ratings

    About 5% of standardized residuals beyond ±2 and 1% beyond ±3 are expected when the model fits.

  • Category use

    A score category with fewer than 10 ratings gives unstable thresholds.

  • Extreme scores

    A person with the lowest or highest score in every rating has no finite estimate and is set aside before fitting.

  • Convergence

    Newton–Raphson reached a step below 1e-10.

  • One underlying traitNot checked from data: state why it holds

    Every rating reflects one ability, with raters and tasks shifting it by a constant; halo effects or raters who weigh criteria differently break this.

What it reports

  • Tests: Raters differ in severity (fixed all-same χ²)
n_obs
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
n_used
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
n_persons
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
n_raters
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
n_items
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
n_extreme
A person with the lowest or the highest score in every rating. Their measure is infinite, so they are set aside before fitting.
categories
Ratings in the data and used in the fit, and the number of persons, raters, tasks and score categories.
loglik
Estimates every person, rater, task and threshold together by maximizing one likelihood, as the Facets program does.
iterations
Estimates every person, rater, task and threshold together by maximizing one likelihood, as the Facets program does.
converged
Estimates every person, rater, task and threshold together by maximizing one likelihood, as the Facets program does.
sep_person
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
rel_person
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
sep_rater
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
rel_rater
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
rater_chisq
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.
rater_df
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.
rater_p
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.
severity_range
A rater's measure in logits. Higher means harsher, so the same performance gets lower scores. Severities are centered at 0.
share_z2
The shares of ratings more than 2 and 3 standard errors from what the model expects; about 5% and 1% fit the model.
share_z3
The shares of ratings more than 2 and 3 standard errors from what the model expects; about 5% and 1% fit the model.
rater_misfit
Average squared standardized residuals of an element's ratings; infit weights by information. About 1 fits; 0.5–1.5 is productive.
thresholds_label
A Rasch model where a rating depends on the person's ability, the rater's severity and the task's difficulty, all in logits on one scale.
sep_item
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
rel_item
How well a facet's measures are told apart. Separation = true spread / measurement error; reliability = true variance / observed variance.
item_chisq
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.
item_df
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.
item_p
Tests whether every element of a facet has the same measure, weighting each by its precision. Small p means real differences.

Per group, level or term: severity[<rater>], se_severity[<rater>], infit[<rater>], outfit[<rater>], difficulty[<item>], se_difficulty[<item>], threshold[<category>], threshold[<scale>|<category>]

Python and R

Python and R agree to 6 decimals (relative tolerance 1e-7). Python uses pandas, numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Default traps between the two languages

  • Both engines run the same joint maximum likelihood (codesplash.stats.facets ↔ cs_facets_fit): full Newton–Raphson with step halving from zero on the concave log-likelihood, sum-to-zero contrasts for raters, items and each threshold set, to a step below 1e-10, so they agree to about 1e-10.
  • The same likelihood fitted as a conditional logit with survival::clogit (one stratum per rating, one row per score category) reproduces the log-likelihood, severities, difficulties, thresholds and person measures after centering (tests/crosscheck/hme2_facets.R). Facets also estimates extreme persons with a fractional score adjustment; here they are set aside and listed.
Python

The exact script CodeSplash ran for example “Essays shared” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Many-facet Rasch model (rater severity)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method measurement.facets 1.0.0 · spec 5ce1e84cfc6bbf10
# Dataset: facets_sim (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import facets as fc  # many-facet Rasch, JML (twin of R's cs_facets_fit)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/facets_sim.parquet", columns=["essay", "rater", "task", "score"])
n_input = len(df)
df["essay"] = pd.Categorical(df["essay"], categories=["e01", "e02", "e03", "e04", "e05", "e06", "e07", "e08", "e09", "e10", "e11", "e12", "e13", "e14", "e15", "e16", "e17", "e18", "e19", "e20", "e21", "e22", "e23", "e24", "e25", "e26", "e27", "e28", "e29", "e30", "e31", "e32", "e33", "e34", "e35", "e36", "e37", "e38", "e39", "e40", "e41"])  # stored level order
df["rater"] = pd.Categorical(df["rater"], categories=["r1", "r2", "r3", "r4"])  # stored level order
df["task"] = pd.Categorical(df["task"], categories=["argument", "evidence", "style"])  # stored level order
df = df.dropna(subset=["essay", "rater", "task", "score"])  # listwise deletion over the analysis columns
df["essay"] = df["essay"].cat.remove_unused_categories()
df["rater"] = df["rater"].cat.remove_unused_categories()
df["task"] = df["task"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["essay", "rater", "task", "score"])  # infinite values stop the run (registry/errors.yaml)

# %% Facets and score categories
person_col, rater_col, score_col = "essay", "rater", "score"
item_col = "task"
persons = [str(x) for x in df[person_col].cat.categories]
raters = [str(x) for x in df[rater_col].cat.categories]
items = [str(x) for x in df[item_col].cat.categories] if item_col else ["All"]
note_gaps = ""
if isinstance(df[score_col].dtype, pd.CategoricalDtype):
    cats = [str(x) for x in df[score_col].cat.categories]
    x = df[score_col].cat.codes.to_numpy(dtype=np.int64)
else:
    v = df[score_col].to_numpy(dtype=float)
    bad = int(np.sum(v != np.round(v)))
    if bad:
        cs.cs_error("CS_E_INVALID_VALUES", column=score_col, requirement="whole numbers (ordered score categories)", count=bad)
    vals = np.unique(v)
    if len(vals) > 15:
        cs.cs_error("CS_E_TOO_MANY_LEVELS", column=score_col, k=len(vals), max=15)
    cats = [str(int(s)) for s in vals]
    x = np.searchsorted(vals, v).astype(np.int64)
    if len(vals) >= 2 and vals[-1] - vals[0] + 1 > len(vals):
        note_gaps = f" Unused score values between {cats[0]} and {cats[-1]} were skipped: the categories are the {len(vals)} values used."
k = len(cats)
if k < 2:
    cs.cs_error("CS_E_TOO_FEW_GROUPS", column=score_col, min=2, k=k)
if k > 15:
    cs.cs_error("CS_E_TOO_MANY_LEVELS", column=score_col, k=k, max=15)
n_p, n_r, n_i = len(persons), len(raters), len(items)
if n_p < 2:
    cs.cs_error("CS_E_TOO_FEW_GROUPS", column=person_col, min=2, k=n_p)
if n_r < 2:
    cs.cs_error("CS_E_TOO_FEW_GROUPS", column=rater_col, min=2, k=n_r)
m = k - 1
person = df[person_col].cat.codes.to_numpy(dtype=np.int64)
rater = df[rater_col].cat.codes.to_numpy(dtype=np.int64)
item = df[item_col].cat.codes.to_numpy(dtype=np.int64) if item_col else np.zeros(len(df), dtype=np.int64)
thresholds = "shared"
if thresholds == "by_item" and not item_col:
    thresholds = "shared"
groups, group_names = {"by_item": (item, items), "by_rater": (rater, raters)}.get(thresholds, (np.zeros(len(df), dtype=np.int64), ["Scale"]))
n_g = len(group_names)

# %% Extreme scores and linkage
active, flags = fc.extremes(person, rater, item, x, n_p, n_r, n_i, m)
if not active.any():
    cs.cs_error("CS_E_UNDEFINED", what="Many-facet Rasch measures", reason="every person has the lowest or highest score in every rating")
subsets = fc.connected(person[active], rater[active], item[active], n_p, n_r, n_i)
if subsets > 1:
    cs.cs_error("CS_E_UNDEFINED", what="Many-facet Rasch measures",
                reason=f"the ratings split into {subsets} groups that share no raters, persons or items, so their measures can't be compared; link them with shared raters")
for g in np.unique(groups[active]):
    used = np.unique(x[active & (groups == g)])
    if len(used) < k:
        miss = [cats[c] for c in range(k) if c not in used]
        where = "" if thresholds == "shared" else f" for {group_names[g]}"
        cs.cs_error("CS_E_UNDEFINED", what="The rating-scale thresholds",
                    reason=f"score {', '.join(miss)} is never given{where} once extreme scores are set aside; use shared thresholds or merge categories")

# %% Fit (joint maximum likelihood)
xa = x[active]
fit = fc.facets_fit(person[active], rater[active], item[active], xa, n_p, n_r, n_i, m, groups[active], n_g)
E, V = fit["expected"], fit["variance"]
z = (xa - E) / np.sqrt(V)
st_p = fc.element_stats(person[active], n_p, xa, E, V)
st_r = fc.element_stats(rater[active], n_r, xa, E, V)
st_i = fc.element_stats(item[active], n_i, xa, E, V)
sep_p = fc.separation(fit["theta"], st_p["se"])
sep_r = fc.separation(fit["alpha"], st_r["se"])
sep_i = fc.separation(fit["beta"], st_i["se"]) if item_col else None
nan = lambda v: None if v is None or not np.isfinite(v) else float(v)  # noqa: E731
thr_label = {"shared": "one rating scale", "by_item": "a scale per item", "by_rater": "a scale per rater"}[thresholds]
misfit = [raters[j] for j in range(n_r) if np.isfinite(st_r["infit"][j]) and not (0.5 <= st_r["infit"][j] <= 1.5 and 0.5 <= st_r["outfit"][j] <= 1.5)]
values = {
    "n_obs": float(len(x)), "n_used": float(active.sum()), "n_persons": float(n_p), "n_raters": float(n_r), "n_items": float(n_i if item_col else 0),
    "n_extreme": float(np.sum(flags[0] != 0)), "categories": float(k), "loglik": float(fit["loglik"]), "iterations": float(fit["iterations"]),
    "converged": 1.0 if fit["converged"] else 0.0,
    "sep_person": nan(sep_p["separation"]), "rel_person": nan(sep_p["reliability"]),
    "sep_rater": nan(sep_r["separation"]), "rel_rater": nan(sep_r["reliability"]),
    "rater_chisq": nan(sep_r["chisq"]), "rater_df": nan(sep_r["df"]), "rater_p": nan(sep_r["p"]),
    "severity_range": float(np.nanmax(fit["alpha"]) - np.nanmin(fit["alpha"])),
    "share_z2": float(np.mean(np.abs(z) > 2)), "share_z3": float(np.mean(np.abs(z) > 3)),
    "rater_misfit": float(len(misfit)), "thresholds_label": thr_label,
}
values.update({"sep_item": None, "rel_item": None, "item_chisq": None, "item_df": None, "item_p": None})  # no task facet: empty
if item_col:
    values.update({"sep_item": nan(sep_i["separation"]), "rel_item": nan(sep_i["reliability"]), "item_chisq": nan(sep_i["chisq"]),
                   "item_df": nan(sep_i["df"]), "item_p": nan(sep_i["p"])})
for j, r in enumerate(raters):
    values[f"severity[{r}]"] = nan(fit["alpha"][j])
    values[f"se_severity[{r}]"] = nan(st_r["se"][j])
    values[f"infit[{r}]"] = nan(st_r["infit"][j])
    values[f"outfit[{r}]"] = nan(st_r["outfit"][j])
if item_col:
    for i, it in enumerate(items):
        values[f"difficulty[{it}]"] = nan(fit["beta"][i])
        values[f"se_difficulty[{it}]"] = nan(st_i["se"][i])
tau = fit["tau"]
for g in range(n_g):
    for h in range(m):
        key = f"threshold[{cats[h + 1]}]" if thresholds == "shared" else f"threshold[{group_names[g]}|{cats[h + 1]}]"
        values[key] = float(tau[g, h])

# %% Assumptions
counts = np.bincount(xa, minlength=k)
rare = [cats[c] for c in range(k) if counts[c] < 10]
assumptions = [
    {"key": "rater_fit", "label": "Rater fit", "status": "warn" if misfit else "pass",
     "detail": f"Infit or outfit outside 0.5–1.5: {', '.join(misfit)}." if misfit else "Every rater's infit and outfit mean squares are within 0.5–1.5."},
    {"key": "residuals", "label": "Unexpected ratings", "status": "warn" if (values["share_z2"] > 0.05 or values["share_z3"] > 0.01) else "pass",
     "detail": f"{values['share_z2']:.1%} of ratings have |z| > 2 and {values['share_z3']:.1%} have |z| > 3 (about 5% and 1% expected)."},
    {"key": "category_use", "label": "Category use", "status": "warn" if rare else "pass",
     "detail": f"Fewer than 10 ratings in: {', '.join(rare)}." if rare else "Every score category has at least 10 ratings."},
    {"key": "extremes", "label": "Extreme scores", "status": "info",
     "detail": f"{int(values['n_extreme'])} person(s) with the lowest or highest score in every rating were set aside (no finite estimate)." if values["n_extreme"] else "No person has an extreme score."},
    {"key": "convergence", "label": "Convergence", "status": "pass" if fit["converged"] else "warn",
     "detail": f"Newton–Raphson {'converged' if fit['converged'] else 'stopped before converging'} after {fit['iterations']} iterations."},
]
if not fit["converged"]:
    warnings.append(cs.cs_warning("CS_W_NO_CONVERGENCE", what="Many-facet Rasch"))

# %% Tables
def facet_rows(names, meas, st, flg=None):
    rows = []
    for e, name in enumerate(names):
        rows.append({"element": name, "measure": nan(meas[e]), "se": nan(st["se"][e]), "infit": nan(st["infit"][e]),
                     "outfit": nan(st["outfit"][e]), "count": int(st["count"][e]), "observed": nan(st["observed"][e]),
                     "status": ("lowest score" if flg is not None and flg[e] < 0 else "highest score" if flg is not None and flg[e] > 0 else "")})
    return rows


fcols = lambda what: [  # noqa: E731
    {"key": "element", "label": what, "type": "string"}, {"key": "measure", "label": "Measure (logits)", "type": "number"},
    {"key": "se", "label": "SE", "type": "number"}, {"key": "infit", "label": "Infit MnSq", "type": "number"},
    {"key": "outfit", "label": "Outfit MnSq", "type": "number"}, {"key": "count", "label": "Ratings", "type": "integer"},
    {"key": "observed", "label": "Mean score (category)", "type": "number"}, {"key": "status", "label": "Extreme", "type": "string"}]
tables = [{"key": "raters", "title": "Raters (higher = more severe)", "columns": fcols("Rater"), "rows": facet_rows(raters, fit["alpha"], st_r, flags[1])}]
if item_col:
    tables.append({"key": "items", "title": "Items (higher = harder)", "columns": fcols("Item"), "rows": facet_rows(items, fit["beta"], st_i, flags[2])})
tables.append({"key": "persons", "title": "Persons (higher = more able)", "columns": fcols("Person"), "rows": facet_rows(persons, fit["theta"], st_p, flags[0])})
thr_rows = [{"scale": group_names[g], "category": cats[h + 1], "threshold": float(tau[g, h])} for g in range(n_g) for h in range(m)]
tables.append({"key": "thresholds", "title": "Rasch–Andrich thresholds", "columns": [
    {"key": "scale", "label": "Scale", "type": "string"}, {"key": "category", "label": "Step up to score", "type": "string"},
    {"key": "threshold", "label": "Threshold (logits)", "type": "number"}], "rows": thr_rows})
sep_rows = [{"facet": "Persons", **{kk: nan(sep_p[kk]) for kk in ("sd", "rmse", "separation", "reliability", "chisq", "df", "p")}},
            {"facet": "Raters", **{kk: nan(sep_r[kk]) for kk in ("sd", "rmse", "separation", "reliability", "chisq", "df", "p")}}]
if item_col:
    sep_rows.append({"facet": "Items", **{kk: nan(sep_i[kk]) for kk in ("sd", "rmse", "separation", "reliability", "chisq", "df", "p")}})
tables.append({"key": "separation", "title": "Separation and reliability", "columns": [
    {"key": "facet", "label": "Facet", "type": "string"}, {"key": "sd", "label": "SD of measures", "type": "number"},
    {"key": "rmse", "label": "RMSE", "type": "number"}, {"key": "separation", "label": "Separation", "type": "number"},
    {"key": "reliability", "label": "Reliability", "type": "number"}, {"key": "chisq", "label": "Fixed χ² (all same)", "type": "number"},
    {"key": "df", "label": "df", "type": "integer"}, {"key": "p", "label": "p", "type": "pvalue"}], "rows": sep_rows})

# %% Charts
wm_f, wm_m, wm_l = [], [], []
facet_order = ["Persons", "Raters"] + (["Items"] if item_col else []) + ["Thresholds"]
for name, meas, labs in [("Persons", fit["theta"], persons), ("Raters", fit["alpha"], raters)] + ([("Items", fit["beta"], items)] if item_col else []):
    for e, lab in enumerate(labs):
        if np.isfinite(meas[e]):
            wm_f.append(name)
            wm_m.append(float(meas[e]))
            wm_l.append(lab)
for g in range(n_g):
    for h in range(m):
        wm_f.append("Thresholds")
        wm_m.append(float(tau[g, h]))
        wm_l.append(cats[h + 1] if thresholds == "shared" else f"{group_names[g]} {cats[h + 1]}")
ra = np.isfinite(fit["alpha"])
charts = [
    cs.chart("wright", "wright-map", "Wright map: persons, raters" + (", items" if item_col else "") + " and thresholds on one logit scale", {
        "facet": cs.col("Facet", wm_f, "categorical", levels=facet_order),
        "measure": cs.col("Measure (logits)", wm_m, "numeric"),
        "label": cs.col("Element", wm_l, "categorical"),
    }),
    cs.chart("severity", "forest", "Rater severity (±1.96 SE)", {
        "label": cs.col("Rater", [raters[j] for j in range(n_r) if ra[j]], "categorical", levels=[raters[j] for j in range(n_r) if ra[j]]),
        "estimate": cs.col("Severity (logits)", [float(fit["alpha"][j]) for j in range(n_r) if ra[j]], "numeric"),
        "low": cs.col("Low", [float(fit["alpha"][j] - 1.96 * st_r["se"][j]) for j in range(n_r) if ra[j]], "numeric"),
        "high": cs.col("High", [float(fit["alpha"][j] + 1.96 * st_r["se"][j]) for j in range(n_r) if ra[j]], "numeric"),
    }, controls={"reference": 0}),
]
grid = np.linspace(-6.0, 6.0, 121)
cur_t, cur_p, cur_s, cur_c = [], [], [], []
for g in range(n_g):
    cum = np.concatenate([[0.0], np.cumsum(tau[g])])
    s = grid[:, None] * np.arange(k)[None, :] - cum[None, :]
    P = np.exp(s - s.max(axis=1, keepdims=True))
    P /= P.sum(axis=1, keepdims=True)
    for c in range(k):
        cur_t += grid.tolist()
        cur_p += P[:, c].tolist()
        cur_s += [group_names[g]] * len(grid)
        cur_c += [cats[c]] * len(grid)
charts.append(cs.chart("categories", "item-curves", "Category probability curves", {
    "theta": cs.col("Measure relative to the rating (logits)", cur_t, "numeric"),
    "probability": cs.col("Probability", cur_p, "numeric"),
    "item": cs.col("Scale", cur_s, "categorical", levels=group_names),
    "category": cs.col("Score", cur_c, "categorical", levels=cats),
}, controls={"kind": "icc"}))

# %% Result
cs.publish({
    "method": "measurement.facets",
    "methodVersion": "1.0.0",
    "title": "Many-facet Rasch model",
    "engine": cs.engine_info("numpy", "scipy", "codesplash"),
    "n": int(active.sum()),
    "summary": f"Many-facet Rasch model ({thr_label}) for {int(active.sum())} ratings by {n_r} raters: rater severities span {values['severity_range']:.2f} logits; rater separation reliability {values['rel_rater'] if values['rel_rater'] is not None else float('nan'):.2f}, person reliability {values['rel_person'] if values['rel_person'] is not None else float('nan'):.2f}.",
    "apa": f"Many-facet Rasch model (JML): rater fixed χ²({int(sep_r['df'])}) = {cs.fmt_num(sep_r['chisq'], 2)}, {cs.fmt_p(sep_r['p'])}; rater separation reliability = {cs.fmt_num(sep_r['reliability'], 2, leading_zero=False)}",
    "statistics": [{"key": "rater_chisq", "label": "Rater fixed χ²", "value": values["rater_chisq"]},
                   {"key": "rater_p", "label": "p", "value": values["rater_p"], "format": "p"},
                   {"key": "rel_rater", "label": "Rater separation reliability", "value": values["rel_rater"]}],
    "tables": tables,
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"Joint maximum likelihood (as in Facets): rater severities{' and item difficulties' if item_col else ''} centered at 0, thresholds centered within each scale; local model SEs (1/√information). JML measures are slightly spread out when an element has few ratings.{note_gaps}"],
    "charts": charts,
    "values": values,
})
R

The exact script CodeSplash ran for example “Essays shared” · R version 4.5.1 (2025-06-13)

# Many-facet Rasch model (rater severity)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method measurement.facets 1.0.0 · spec 5ce1e84cfc6bbf10
# Dataset: facets_sim (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/facets_sim.parquet", col_select = c("essay", "rater", "task", "score")))
n_input <- nrow(df)
df[["essay"]] <- factor(df[["essay"]], levels = c("e01", "e02", "e03", "e04", "e05", "e06", "e07", "e08", "e09", "e10", "e11", "e12", "e13", "e14", "e15", "e16", "e17", "e18", "e19", "e20", "e21", "e22", "e23", "e24", "e25", "e26", "e27", "e28", "e29", "e30", "e31", "e32", "e33", "e34", "e35", "e36", "e37", "e38", "e39", "e40", "e41"))  # stored level order
df[["rater"]] <- factor(df[["rater"]], levels = c("r1", "r2", "r3", "r4"))  # stored level order
df[["task"]] <- factor(df[["task"]], levels = c("argument", "evidence", "style"))  # stored level order
df <- df[stats::complete.cases(df[c("essay", "rater", "task", "score")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("essay", "rater", "task", "score"))  # infinite values stop the run (registry/errors.yaml)

# %% Facets and score categories
person_col <- "essay"
rater_col <- "rater"
score_col <- "score"
item_col <- "task"
persons <- levels(df[[person_col]])
raters <- levels(df[[rater_col]])
items <- if (!is.null(item_col)) levels(df[[item_col]]) else "All"
note_gaps <- ""
if (is.factor(df[[score_col]])) {
  cats <- levels(df[[score_col]])
  x <- as.integer(df[[score_col]]) - 1L
} else {
  v <- as.numeric(df[[score_col]])
  bad <- sum(v != round(v))
  if (bad) cs_error("CS_E_INVALID_VALUES", column = score_col, requirement = "whole numbers (ordered score categories)", count = bad)
  vals <- sort(unique(v))
  if (length(vals) > 15) cs_error("CS_E_TOO_MANY_LEVELS", column = score_col, k = length(vals), max = 15)
  cats <- as.character(as.integer(vals))
  x <- match(v, vals) - 1L
  if (length(vals) >= 2 && vals[length(vals)] - vals[1] + 1 > length(vals))
    note_gaps <- sprintf(" Unused score values between %s and %s were skipped: the categories are the %d values used.", cats[1], cats[length(cats)], length(vals))
}
k <- length(cats)
if (k < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = score_col, min = 2, k = k)
if (k > 15) cs_error("CS_E_TOO_MANY_LEVELS", column = score_col, k = k, max = 15)
n_p <- length(persons)
n_r <- length(raters)
n_i <- length(items)
if (n_p < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = person_col, min = 2, k = n_p)
if (n_r < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = rater_col, min = 2, k = n_r)
m <- k - 1L
person <- as.integer(df[[person_col]])
rater <- as.integer(df[[rater_col]])
item <- if (!is.null(item_col)) as.integer(df[[item_col]]) else rep(1L, nrow(df))
thresholds <- "shared"
if (thresholds == "by_item" && is.null(item_col)) thresholds <- "shared"
if (thresholds == "by_item") {
  groups <- item
  group_names <- items
} else if (thresholds == "by_rater") {
  groups <- rater
  group_names <- raters
} else {
  groups <- rep(1L, nrow(df))
  group_names <- "Scale"
}
n_g <- length(group_names)

# %% Extreme scores and linkage
ex <- cs_facets_extremes(person, rater, item, x, n_p, n_r, n_i, m)
active <- ex$active
flags <- ex$flags
if (!any(active)) cs_error("CS_E_UNDEFINED", what = "Many-facet Rasch measures", reason = "every person has the lowest or highest score in every rating")
subsets <- cs_facets_connected(person[active], rater[active], item[active], n_p, n_r, n_i)
if (subsets > 1) cs_error("CS_E_UNDEFINED", what = "Many-facet Rasch measures",
                          reason = sprintf("the ratings split into %d groups that share no raters, persons or items, so their measures can't be compared; link them with shared raters", subsets))
for (g in sort(unique(groups[active]))) {
  used <- unique(x[active & groups == g])
  if (length(used) < k) {
    miss <- cats[!(seq_len(k) - 1L) %in% used]
    where <- if (thresholds == "shared") "" else sprintf(" for %s", group_names[g])
    cs_error("CS_E_UNDEFINED", what = "The rating-scale thresholds",
             reason = sprintf("score %s is never given%s once extreme scores are set aside; use shared thresholds or merge categories", paste(miss, collapse = ", "), where))
  }
}

# %% Fit (joint maximum likelihood)
xa <- x[active]
fit <- cs_facets_fit(person[active], rater[active], item[active], xa, n_p, n_r, n_i, m, groups[active], n_g)
E <- fit$expected
V <- fit$variance
z <- (xa - E) / sqrt(V)
st_p <- cs_facets_element_stats(person[active], n_p, xa, E, V)
st_r <- cs_facets_element_stats(rater[active], n_r, xa, E, V)
st_i <- cs_facets_element_stats(item[active], n_i, xa, E, V)
sep_p <- cs_facets_separation(fit$theta, st_p$se)
sep_r <- cs_facets_separation(fit$alpha, st_r$se)
sep_i <- if (!is.null(item_col)) cs_facets_separation(fit$beta, st_i$se) else NULL
fin <- function(v) if (is.null(v) || length(v) == 0 || !is.finite(v)) NA_real_ else unname(v)
thr_label <- c(shared = "one rating scale", by_item = "a scale per item", by_rater = "a scale per rater")[[thresholds]]
misfit <- raters[is.finite(st_r$infit) & !(st_r$infit >= 0.5 & st_r$infit <= 1.5 & st_r$outfit >= 0.5 & st_r$outfit <= 1.5)]
values <- list(
  n_obs = length(x), n_used = sum(active), n_persons = n_p, n_raters = n_r, n_items = if (!is.null(item_col)) n_i else 0,
  n_extreme = sum(flags[[1]] != 0), categories = k, loglik = fit$loglik, iterations = fit$iterations,
  converged = if (fit$converged) 1 else 0,
  sep_person = fin(sep_p$separation), rel_person = fin(sep_p$reliability),
  sep_rater = fin(sep_r$separation), rel_rater = fin(sep_r$reliability),
  rater_chisq = fin(sep_r$chisq), rater_df = fin(sep_r$df), rater_p = fin(sep_r$p),
  severity_range = max(fit$alpha, na.rm = TRUE) - min(fit$alpha, na.rm = TRUE),
  share_z2 = mean(abs(z) > 2), share_z3 = mean(abs(z) > 3),
  rater_misfit = length(misfit), thresholds_label = thr_label
)
values[c("sep_item", "rel_item", "item_chisq", "item_df", "item_p")] <- list(NA_real_)  # no task facet: empty
if (!is.null(item_col)) {
  values$sep_item <- fin(sep_i$separation)
  values$rel_item <- fin(sep_i$reliability)
  values$item_chisq <- fin(sep_i$chisq)
  values$item_df <- fin(sep_i$df)
  values$item_p <- fin(sep_i$p)
}
for (j in seq_len(n_r)) {
  r <- raters[j]
  values[[sprintf("severity[%s]", r)]] <- fin(fit$alpha[j])
  values[[sprintf("se_severity[%s]", r)]] <- fin(st_r$se[j])
  values[[sprintf("infit[%s]", r)]] <- fin(st_r$infit[j])
  values[[sprintf("outfit[%s]", r)]] <- fin(st_r$outfit[j])
}
if (!is.null(item_col)) {
  for (i in seq_len(n_i)) {
    values[[sprintf("difficulty[%s]", items[i])]] <- fin(fit$beta[i])
    values[[sprintf("se_difficulty[%s]", items[i])]] <- fin(st_i$se[i])
  }
}
tau <- fit$tau
for (g in seq_len(n_g)) {
  for (h in seq_len(m)) {
    key <- if (thresholds == "shared") sprintf("threshold[%s]", cats[h + 1]) else sprintf("threshold[%s|%s]", group_names[g], cats[h + 1])
    values[[key]] <- tau[g, h]
  }
}

# %% Assumptions
counts <- tabulate(xa + 1L, k)
rare <- cats[counts < 10]
pct1 <- function(v) sprintf("%.1f%%", 100 * v)
assumptions <- list(
  list(key = "rater_fit", label = "Rater fit", status = if (length(misfit)) "warn" else "pass",
       detail = if (length(misfit)) sprintf("Infit or outfit outside 0.5–1.5: %s.", paste(misfit, collapse = ", ")) else "Every rater's infit and outfit mean squares are within 0.5–1.5."),
  list(key = "residuals", label = "Unexpected ratings", status = if (values$share_z2 > 0.05 || values$share_z3 > 0.01) "warn" else "pass",
       detail = sprintf("%s of ratings have |z| > 2 and %s have |z| > 3 (about 5%% and 1%% expected).", pct1(values$share_z2), pct1(values$share_z3))),
  list(key = "category_use", label = "Category use", status = if (length(rare)) "warn" else "pass",
       detail = if (length(rare)) sprintf("Fewer than 10 ratings in: %s.", paste(rare, collapse = ", ")) else "Every score category has at least 10 ratings."),
  list(key = "extremes", label = "Extreme scores", status = "info",
       detail = if (values$n_extreme > 0) sprintf("%d person(s) with the lowest or highest score in every rating were set aside (no finite estimate).", as.integer(values$n_extreme)) else "No person has an extreme score."),
  list(key = "convergence", label = "Convergence", status = if (fit$converged) "pass" else "warn",
       detail = sprintf("Newton–Raphson %s after %d iterations.", if (fit$converged) "converged" else "stopped before converging", fit$iterations))
)
if (!fit$converged) warnings <- c(warnings, cs_warning("CS_W_NO_CONVERGENCE", what = "Many-facet Rasch"))

# %% Tables
facet_rows <- function(names, meas, st, flg) {
  lapply(seq_along(names), function(e) list(element = names[e], measure = fin(meas[e]), se = fin(st$se[e]), infit = fin(st$infit[e]),
                                            outfit = fin(st$outfit[e]), count = as.integer(st$count[e]), observed = fin(st$observed[e]),
                                            status = if (flg[e] < 0) "lowest score" else if (flg[e] > 0) "highest score" else ""))
}
fcols <- function(what) list(
  list(key = "element", label = what, type = "string"), list(key = "measure", label = "Measure (logits)", type = "number"),
  list(key = "se", label = "SE", type = "number"), list(key = "infit", label = "Infit MnSq", type = "number"),
  list(key = "outfit", label = "Outfit MnSq", type = "number"), list(key = "count", label = "Ratings", type = "integer"),
  list(key = "observed", label = "Mean score (category)", type = "number"), list(key = "status", label = "Extreme", type = "string"))
tables <- list(list(key = "raters", title = "Raters (higher = more severe)", columns = fcols("Rater"), rows = facet_rows(raters, fit$alpha, st_r, flags[[2]])))
if (!is.null(item_col)) tables[[length(tables) + 1]] <- list(key = "items", title = "Items (higher = harder)", columns = fcols("Item"),
                                                            rows = facet_rows(items, fit$beta, st_i, flags[[3]]))
tables[[length(tables) + 1]] <- list(key = "persons", title = "Persons (higher = more able)", columns = fcols("Person"),
                                     rows = facet_rows(persons, fit$theta, st_p, flags[[1]]))
thr_rows <- list()
for (g in seq_len(n_g)) for (h in seq_len(m)) thr_rows[[length(thr_rows) + 1]] <- list(scale = group_names[g], category = cats[h + 1], threshold = tau[g, h])
tables[[length(tables) + 1]] <- list(key = "thresholds", title = "Rasch–Andrich thresholds", columns = list(
  list(key = "scale", label = "Scale", type = "string"), list(key = "category", label = "Step up to score", type = "string"),
  list(key = "threshold", label = "Threshold (logits)", type = "number")), rows = thr_rows)
sep_row <- function(name, s) c(list(facet = name), lapply(s[c("sd", "rmse", "separation", "reliability", "chisq", "df", "p")], fin))
sep_rows <- list(sep_row("Persons", sep_p), sep_row("Raters", sep_r))
if (!is.null(item_col)) sep_rows[[3]] <- sep_row("Items", sep_i)
tables[[length(tables) + 1]] <- list(key = "separation", title = "Separation and reliability", columns = list(
  list(key = "facet", label = "Facet", type = "string"), list(key = "sd", label = "SD of measures", type = "number"),
  list(key = "rmse", label = "RMSE", type = "number"), list(key = "separation", label = "Separation", type = "number"),
  list(key = "reliability", label = "Reliability", type = "number"), list(key = "chisq", label = "Fixed χ² (all same)", type = "number"),
  list(key = "df", label = "df", type = "integer"), list(key = "p", label = "p", type = "pvalue")), rows = sep_rows)

# %% Charts
facet_order <- c("Persons", "Raters", if (!is.null(item_col)) "Items", "Thresholds")
parts <- list(list("Persons", fit$theta, persons), list("Raters", fit$alpha, raters))
if (!is.null(item_col)) parts[[3]] <- list("Items", fit$beta, items)
wm_f <- character(0)
wm_m <- numeric(0)
wm_l <- character(0)
for (pp in parts) {
  ok <- is.finite(pp[[2]])
  wm_f <- c(wm_f, rep(pp[[1]], sum(ok)))
  wm_m <- c(wm_m, pp[[2]][ok])
  wm_l <- c(wm_l, pp[[3]][ok])
}
for (g in seq_len(n_g)) for (h in seq_len(m)) {
  wm_f <- c(wm_f, "Thresholds")
  wm_m <- c(wm_m, tau[g, h])
  wm_l <- c(wm_l, if (thresholds == "shared") cats[h + 1] else paste(group_names[g], cats[h + 1]))
}
ra <- is.finite(fit$alpha)
charts <- list(
  cs_chart("wright", "wright-map", paste0("Wright map: persons, raters", if (!is.null(item_col)) ", items" else "", " and thresholds on one logit scale"), list(
    facet = cs_col("Facet", wm_f, "categorical", levels = facet_order),
    measure = cs_col("Measure (logits)", wm_m, "numeric"),
    label = cs_col("Element", wm_l, "categorical")
  )),
  cs_chart("severity", "forest", "Rater severity (±1.96 SE)", list(
    label = cs_col("Rater", raters[ra], "categorical", levels = raters[ra]),
    estimate = cs_col("Severity (logits)", fit$alpha[ra], "numeric"),
    low = cs_col("Low", fit$alpha[ra] - 1.96 * st_r$se[ra], "numeric"),
    high = cs_col("High", fit$alpha[ra] + 1.96 * st_r$se[ra], "numeric")
  ), controls = list(reference = 0))
)
grid <- seq(-6, 6, length.out = 121)
cur_t <- numeric(0)
cur_p <- numeric(0)
cur_s <- character(0)
cur_c <- character(0)
for (g in seq_len(n_g)) {
  cum <- c(0, cumsum(tau[g, ]))
  s <- outer(grid, 0:(k - 1)) - matrix(cum, length(grid), k, byrow = TRUE)
  P <- exp(s - apply(s, 1, max))
  P <- P / rowSums(P)
  for (c0 in seq_len(k)) {
    cur_t <- c(cur_t, grid)
    cur_p <- c(cur_p, P[, c0])
    cur_s <- c(cur_s, rep(group_names[g], length(grid)))
    cur_c <- c(cur_c, rep(cats[c0], length(grid)))
  }
}
charts[[3]] <- cs_chart("categories", "item-curves", "Category probability curves", list(
  theta = cs_col("Measure relative to the rating (logits)", cur_t, "numeric"),
  probability = cs_col("Probability", cur_p, "numeric"),
  item = cs_col("Scale", cur_s, "categorical", levels = group_names),
  category = cs_col("Score", cur_c, "categorical", levels = cats)
), controls = list(kind = "icc"))

# %% Result
cs_publish(list(
  method = "measurement.facets",
  methodVersion = "1.0.0",
  title = "Many-facet Rasch model",
  engine = cs_engine_info("stats", "codesplashr"),
  n = sum(active),
  summary = sprintf("Many-facet Rasch model (%s) for %d ratings by %d raters: rater severities span %.2f logits; rater separation reliability %.2f, person reliability %.2f.",
                    thr_label, sum(active), n_r, values$severity_range, values$rel_rater, values$rel_person),
  apa = sprintf("Many-facet Rasch model (JML): rater fixed χ²(%d) = %s, %s; rater separation reliability = %s", as.integer(sep_r$df),
                cs_fmt_num(sep_r$chisq, 2), cs_fmt_p(sep_r$p), cs_fmt_num(sep_r$reliability, 2, leading_zero = FALSE)),
  statistics = list(list(key = "rater_chisq", label = "Rater fixed χ²", value = values$rater_chisq),
                    list(key = "rater_p", label = "p", value = values$rater_p, format = "p"),
                    list(key = "rel_rater", label = "Rater separation reliability", value = values$rel_rater)),
  tables = tables,
  assumptions = assumptions,
  warnings = warnings,
  notes = list(sprintf("Joint maximum likelihood (as in Facets): rater severities%s centered at 0, thresholds centered within each scale; local model SEs (1/√information). JML measures are slightly spread out when an element has few ratings.%s",
                       if (!is.null(item_col)) " and item difficulties" else "", note_gaps)),
  charts = charts,
  values = values
))

Sources

  • Linacre, J. M. (1989). Many-faceted Rasch measurement. MESA Press.
  • Andrich, D. (1978). A rating formulation for ordered response categories. Psychometrika, 43(4), 561–573.
  • Eckes, T. (2015). Introduction to many-facet Rasch measurement (2nd ed.). Peter Lang.

From the CodeSplash method registry · measurement.facets v1.0.0.