Skip to contents

llmmetric treats large language models (LLMs) explicitly as fallible psychometric measurement instruments. It integrates four tightly connected layers:

  1. Multi-Facet Structured Coding Engine — reproducible unit x prompt x model x temperature x replicate orchestration with strict JSON schema validation, content-addressed caching, retry handling, and pluggable backends (backend_openai(), backend_ollama(), backend_mock()).
  2. LLM Psychometrics & Generalizability Suite — Generalizability Theory (g_study(), d_study()), calibration against human gold standards (calibration_metrics()), and temporal/version drift diagnostics (check_drift()).
  3. Differential Prompt Functioning (DPF) & Fairness Diagnostics — uniform and non-uniform measurement invariance testing across demographic or experimental subgroups (dpf_test()), including prompt-level FDR screening and prompt-by-group interaction tests.
  4. Measurement-Error-Corrected Downstream Inference — Prediction-Powered Inference (ppi_mean(), ppi_lm(), ppi_glm()), optimal power-tuning (PPI++), and clustered/multilevel extensions (ppi_clustered(), ppi_lmer()) providing asymptotically valid parameter estimates, confidence intervals, and hypothesis tests when combining large LLM-annotated datasets with smaller human-validated subsets.

1. Formal Statistical Formulation

1.1 Generalizability Theory (G-Study and D-Study)

Let Yu,f1,…,fK,rY_{u, f_1, \dots, f_K, r} denote the numeric score assigned to measurement object (unit/text/person) u∈{1,…,nu}u \in \{1, \dots, n_u\} under crossed measurement facets fk∈{1,…,nfk}f_k \in \{1, \dots, n_{f_k}\} (k=1,…,Kk = 1, \dots, K, such as prompt pp, model mm, temperature tt) and replicate r∈{1,…,nr}r \in \{1, \dots, n_r\}.

Under a fully crossed random-effects G-theory model (Brennan, 2001; Shavelson & Webb, 1991), the observed score decomposes into orthogonal random effects indexed by non-empty subsets S⊆{u}∪ℱS \subseteq \{u\} \cup \mathcal{F}, where ℱ={f1,…,fK}\mathcal{F} = \{f_1, \dots, f_K\}:

Yu,f1,…,fK,r=μ+∑∅≠S⊆{u}∪ℱvS+eu,f1,…,fK,r,vS∼ind(0,σS2),e∼(0,σe2). Y_{u, f_1, \dots, f_K, r} = \mu + \sum_{\emptyset \neq S \subseteq \{u\} \cup \mathcal{F}} v_S + e_{u, f_1, \dots, f_K, r}, \qquad v_S \stackrel{\text{ind}}{\sim} (0, \sigma_S^2), \quad e \sim (0, \sigma_e^2).

For the canonical two-facet crossed design (u×p×mu \times p \times m, without replicates nr=1n_r = 1), the highest-order interaction u×p×mu \times p \times m is confounded with residual error:

Yupm=μ+vu+vp+vm+vup+vum+vpm+vupm,e. Y_{upm} = \mu + v_u + v_p + v_m + v_{up} + v_{um} + v_{pm} + v_{upm,e}.

Variance Component Estimation

  • REML (primary): Estimated via lme4::lmer(..., REML = TRUE) with crossed random intercepts for u, each facet fkf_k, and interaction terms up to the estimable order. REML naturally handles unbalanced designs and guarantees non-negative variance component estimates (σ̂S2≥0\hat{\sigma}_S^2 \ge 0).
  • Expected Mean Squares / ANOVA (fallback & option): For balanced designs or when REML fails to converge, g_study() solves the exact linear system of Type-I/balanced ANOVA expected mean squares and truncates negative variance estimates to zero per Brennan (2001).

Error Variances and Reliability Coefficients

For a Decision Study (D-study) aggregating scores over facet sizes 𝐧=(nf1,…,nfK)\mathbf{n} = (n_{f_1}, \dots, n_{f_K}) and nrn_r replicates per cell:

  • Universe-score variance: στ2=σu2\sigma_\tau^2 = \sigma_u^2.
  • Relative error variance (relevant for rank-ordering units): sums all components involving both uu and at least one facet, plus residual error: σδ2(𝐧)=∑S∋uS∩ℱ≠∅σS2∏f∈S∩ℱnf+σe2nr∏f∈ℱnf. \sigma_\delta^2(\mathbf{n}) = \sum_{\substack{S \ni u \\ S \cap \mathcal{F} \neq \emptyset}} \frac{\sigma_S^2}{\prod_{f \in S \cap \mathcal{F}} n_f} + \frac{\sigma_e^2}{n_r \prod_{f \in \mathcal{F}} n_f}.
  • Absolute error variance (relevant for absolute cutoffs, criterion-referenced scoring, and mean comparisons): adds all facet main effects and pure facet interactions: σΔ2(𝐧)=σδ2(𝐧)+∑S∌uS∩ℱ≠∅σS2∏f∈S∩ℱnf. \sigma_\Delta^2(\mathbf{n}) = \sigma_\delta^2(\mathbf{n}) + \sum_{\substack{S \not\ni u \\ S \cap \mathcal{F} \neq \emptyset}} \frac{\sigma_S^2}{\prod_{f \in S \cap \mathcal{F}} n_f}.
  • Generalizability coefficient (Eρ2E\rho^2) and Dependability index (Φ\Phi): Eρ2(𝐧)=σu2σu2+σδ2(𝐧),Φ(𝐧)=σu2σu2+σΔ2(𝐧). E\rho^2(\mathbf{n}) = \frac{\sigma_u^2}{\sigma_u^2 + \sigma_\delta^2(\mathbf{n})}, \qquad \Phi(\mathbf{n}) = \frac{\sigma_u^2}{\sigma_u^2 + \sigma_\Delta^2(\mathbf{n})}.

For the two-facet u×p×mu \times p \times m design (nr=1n_r = 1), this simplifies to:

σδ2(np,nm)=σup2np+σum2nm+σupm,e2npnm,σΔ2(np,nm)=σp2np+σm2nm+σpm2npnm+σδ2(np,nm). \sigma_\delta^2(n_p, n_m) = \frac{\sigma_{up}^2}{n_p} + \frac{\sigma_{um}^2}{n_m} + \frac{\sigma_{upm,e}^2}{n_p n_m}, \qquad \sigma_\Delta^2(n_p, n_m) = \frac{\sigma_p^2}{n_p} + \frac{\sigma_m^2}{n_m} + \frac{\sigma_{pm}^2}{n_p n_m} + \sigma_\delta^2(n_p, n_m).

d_study() evaluates (Eρ2,Φ)(E\rho^2, \Phi) over a user-specified grid of facet counts, computes single-facet asymptotes (e.g., lim⁡np→∞Eρ2(np,nm)\lim_{n_p \to \infty} E\rho^2(n_p, n_m)), and identifies minimum-cost designs attaining a target reliability threshold (e.g., ≥0.85\ge 0.85).


1.2 Calibration Metrics and Drift Testing

Calibration vs. Human Gold Standards (calibration_metrics())

For human gold-standard scores YiY_i and LLM scores Ŷi\hat{Y}_i (i=1,…,ni = 1, \dots, n):

  • Continuous outcomes: Pearson rr, Spearman ρ\rho, Lin’s Concordance Correlation Coefficient (CCC), two-way random absolute-agreement ICC(A,1)\text{ICC}(A,1) and consistency ICC(C,1)\text{ICC}(C,1), MAE, RMSE, mean bias (Ŷ‾−Y‾\bar{\hat{Y}} - \bar{Y}), SD ratio, and calibration regression Yi=α+βŶi+εiY_i = \alpha + \beta \hat{Y}_i + \varepsilon_i with joint FF-test of ideal calibration H0:(α,β)=(0,1)H_0: (\alpha, \beta) = (0, 1).
  • Categorical/ordinal outcomes: Accuracy, Macro-F1F_1, unweighted and linearly/quadratically weighted Cohen’s κ\kappa, and exact coincidence-matrix Krippendorff’s α\alpha (nominal or ordinal metric).

Temporal & Model-Version Drift (check_drift())

Given anchor texts scored across timepoints or model versions v∈{1,…,V}v \in \{1, \dots, V\} with baseline v0v_0:

  • Tests overall mean invariance via within-unit repeated-measures modeling (score ~ version + (1 | unit_id) / paired comparisons), reporting paired mean shift, paired Cohen’s dzd_z, variance ratio, anchor-set Pearson rr, Spearman ρ\rho, ICC(A,1)\text{ICC}(A,1), MAE, and two-sample Kolmogorov-Smirnov statistic DD against v0v_0.

1.3 Differential Prompt Functioning (DPF) & Measurement Invariance

Adapting psychometric Differential Item Functioning (Swaminathan & Rogers, 1990; Zumbo, 1999) to LLM scoring, dpf_test() tests whether LLM score SiS_i exhibits subgroup-dependent bias across observed group GiG_i conditional on human gold-standard score YiY_i:

  • Model 0 (Invariant): g(𝔼[Si∣Yi])=β0+β1Yig(\mathbb{E}[S_i \mid Y_i]) = \beta_0 + \beta_1 Y_i (or polynomial basis Pd(Yi)P_d(Y_i))
  • Model 1 (Uniform DPF): g(𝔼[Si∣Yi,Gi])=β0+β1Yi+𝛄⊤𝐃(Gi)g(\mathbb{E}[S_i \mid Y_i, G_i]) = \beta_0 + \beta_1 Y_i + \boldsymbol{\gamma}^\top \mathbf{D}(G_i)
  • Model 2 (Non-Uniform DPF): g(𝔼[Si∣Yi,Gi])=β0+β1Yi+𝛄⊤𝐃(Gi)+𝛈⊤(Yi⋅𝐃(Gi))g(\mathbb{E}[S_i \mid Y_i, G_i]) = \beta_0 + \beta_1 Y_i + \boldsymbol{\gamma}^\top \mathbf{D}(G_i) + \boldsymbol{\eta}^\top (Y_i \cdot \mathbf{D}(G_i))

where gg is the identity link for continuous scores (OLS) or logit link for binary scores (binomial GLM).

  • Hypothesis tests:
    • Uniform DPF: H0:𝛄=𝟎H_0: \boldsymbol{\gamma} = \mathbf{0} (Model 1 vs. Model 0)
    • Non-uniform DPF: H0:𝛈=𝟎H_0: \boldsymbol{\eta} = \mathbf{0} (Model 2 vs. Model 1)
    • Omnibus (Total) DPF: H0:𝛄=𝟎,𝛈=𝟎H_0: \boldsymbol{\gamma} = \mathbf{0}, \boldsymbol{\eta} = \mathbf{0} (Model 2 vs. Model 0)
    • When repeated rows per unit exist (e.g., multiple prompts per unit), dpf_test() computes unit-clustered sandwich Wald χ2\chi^2 tests to prevent pseudoreplication Type-I error inflation.
  • Effect sizes: ΔR2\Delta R^2 (OLS) or Nagelkerke ΔRN2\Delta R_N^2 (logistic), Cohen’s f2f^2, and conditional subgroup bias estimates at Y‾\bar{Y} with standard errors and 95% confidence intervals.
  • Prompt-level screening: When prompt_col is supplied, dpf_test() runs per-prompt DPF tests with Benjamini-Hochberg FDR adjustment and tests the global Prompt ×\times Group interaction controlling for YiY_i.

1.4 Prediction-Powered Inference (PPI, PPI++, and Clustered/Multilevel Extensions)

Let the observed data consist of: - Labeled validation sample ℒ={(Xi,Yi,Ŷi)}i=1n\mathcal{L} = \{(X_i, Y_i, \hat{Y}_i)\}_{i=1}^n with human gold standard YiY_i and LLM score Ŷi\hat{Y}_i, - Unlabeled sample 𝒰={(Xju,Ŷju)}j=1N\mathcal{U} = \{(X_j^u, \hat{Y}_j^u)\}_{j=1}^N with covariates and LLM scores only, drawn independently from the same population.

Let θ*=arg⁡min⁡θ𝔼[ℓθ(X,Y)]\theta^* = \arg\min_\theta \mathbb{E}[\ell_\theta(X, Y)] denote the target population parameter solving 𝔼[gθ(X,Y)]=0\mathbb{E}[g_\theta(X, Y)] = 0, where gθ=∇θℓθg_\theta = \nabla_\theta \ell_\theta.

Power-Tuned M-Estimation (ppi_mean(), ppi_lm(), ppi_glm())

Following Angelopoulos, Bates, Fannjiang, Jordan, & Zrnic (2023) and Angelopoulos, Duchi, & Zrnic (2024), the PPI++ objective with tuning weight λ\lambda is:

LλPPI++(θ)=1n∑i∈ℒℓθ(Xi,Yi)+λ(1N∑j∈𝒰ℓθ(Xju,Ŷju)−1n∑i∈ℒℓθ(Xi,Ŷi)). L_\lambda^{\text{PPI++}}(\theta) = \frac{1}{n}\sum_{i \in \mathcal{L}} \ell_\theta(X_i, Y_i) + \lambda\left(\frac{1}{N}\sum_{j \in \mathcal{U}} \ell_\theta(X_j^u, \hat{Y}_j^u) - \frac{1}{n}\sum_{i \in \mathcal{L}} \ell_\theta(X_i, \hat{Y}_i)\right).

  • λ=0\lambda = 0 recovers the classical human-only estimator; λ=1\lambda = 1 recovers standard PPI.
  • Because 𝔼[∇θℓθ*(Xu,Ŷu)−∇θℓθ*(X,Ŷ)]=𝟎\mathbb{E}[\nabla_\theta \ell_{\theta^*}(X^u, \hat{Y}^u) - \nabla_\theta \ell_{\theta^*}(X, \hat{Y})] = \mathbf{0} for any (possibly biased, noisy, or nonlinearly distorted) LLM predictor Ŷ\hat{Y}, θ̂λ=arg⁡min⁡θLλPPI++(θ)\hat{\theta}_\lambda = \arg\min_\theta L_\lambda^{\text{PPI++}}(\theta) is consistent and asymptotically normal around θ*\theta^*: n(θ̂λ−θ*)→d𝒩(𝟎,H−1Σ(λ)H−1), \sqrt{n}(\hat{\theta}_\lambda - \theta^*) \xrightarrow{d} \mathcal{N}\!\left(\mathbf{0},\; H^{-1} \Sigma(\lambda) H^{-1}\right), with plug-in sandwich covariance: Var̂(θ̂λ)=Ĥλ−1[1nCov̂ℒ(gi(θ̂λ)−λg̃i(θ̂λ))+λ2NCov̂𝒰(g̃ju(θ̂λ))]Ĥλ−1, \widehat{\text{Var}}(\hat{\theta}_\lambda) = \hat{H}_\lambda^{-1}\left[ \frac{1}{n}\widehat{\text{Cov}}_{\mathcal{L}}\!\big(g_i(\hat{\theta}_\lambda) - \lambda \tilde{g}_i(\hat{\theta}_\lambda)\big) + \frac{\lambda^2}{N}\widehat{\text{Cov}}_{\mathcal{U}}\!\big(\tilde{g}_j^u(\hat{\theta}_\lambda)\big) \right]\hat{H}_\lambda^{-1}, where g̃i(θ)=∇θℓθ(Xi,Ŷi)\tilde{g}_i(\theta) = \nabla_\theta \ell_\theta(X_i, \hat{Y}_i) and sample covariances are explicitly centered to account for non-zero 𝔼[g̃i(θ*)]\mathbb{E}[\tilde{g}_i(\theta^*)] under biased LLMs.
  • Canonical-link GLMs (gaussian, binomial, poisson): For cumulant b(η)b(\eta) with μ(η)=b′(η)\mu(\eta) = b'(\eta) and v(η)=b″(η)v(\eta) = b''(\eta), the Hessian Ĥλ(θ)=(1−λ)1nXℒ⊤Wℒ(θ)Xℒ+λ1NX𝒰⊤W𝒰(θ)X𝒰\hat{H}_\lambda(\theta) = (1 - \lambda)\frac{1}{n}X_{\mathcal{L}}^\top W_{\mathcal{L}}(\theta) X_{\mathcal{L}} + \lambda\frac{1}{N}X_{\mathcal{U}}^\top W_{\mathcal{U}}(\theta) X_{\mathcal{U}} is strictly positive definite for all λ∈[0,1]\lambda \in [0, 1], solved via damped Newton-Raphson / IRLS.
  • Optimal power tuning (λ̂*\hat{\lambda}^*): Minimizing tr(Var̂(θ̂λ))\text{tr}\big(\widehat{\text{Var}}(\hat{\theta}_\lambda)\big) yields: λ̂*=tr(Ĥ−1Ĉg,g̃Ĥ−1)(1+nN)tr(Ĥ−1V̂g̃Ĥ−1), \hat{\lambda}^* = \frac{\text{tr}\!\left(\hat{H}^{-1} \hat{C}_{g,\tilde{g}} \hat{H}^{-1}\right)}{\left(1 + \frac{n}{N}\right)\text{tr}\!\left(\hat{H}^{-1} \hat{V}_{\tilde{g}} \hat{H}^{-1}\right)}, where Ĉg,g̃=Cov̂ℒ(gi,g̃i)\hat{C}_{g,\tilde{g}} = \widehat{\text{Cov}}_{\mathcal{L}}(g_i, \tilde{g}_i) and V̂g̃=Cov̂ℒ∪𝒰(g̃)\hat{V}_{\tilde{g}} = \widehat{\text{Cov}}_{\mathcal{L}\cup\mathcal{U}}(\tilde{g}). For ppi_mean(), λ̂*\hat{\lambda}^* is unconstrained (exact optimal control variate); for ppi_lm() and ppi_glm(), λ̂*\hat{\lambda}^* is clipped to [0,1][0, 1] to preserve finite-sample convexity of LλL_\lambda.
  • Coordinate-wise Control-Variate Calibration (method = "calibrated"): Fits separate models on ℒ\mathcal{L} (human), ℒ\mathcal{L} (LLM), and 𝒰\mathcal{U} (LLM) to compute θ̂cv=θ̂ℒ+Λ̂*(θ̂𝒰̃−θ̂ℒ̃)\hat{\theta}_{\text{cv}} = \hat{\theta}_{\mathcal{L}} + \hat{\Lambda}^*(\hat{\theta}_{\tilde{\mathcal{U}}} - \hat{\theta}_{\tilde{\mathcal{L}}}) using coordinate-optimal influence-function weights Λ̂*=diag(λ̂1*,…,λ̂p*)\hat{\Lambda}^* = \text{diag}(\hat{\lambda}_1^*, \dots, \hat{\lambda}_p^*). This estimator handles severe slope attenuation and LLM-coded predictors seamlessly while preserving valid sandwich inference.

Clustered & Multilevel PPI++ (ppi_clustered(), ppi_lmer())

Suppose observations belong to clusters c∈𝒞=𝒞ℒ∪𝒞𝒰c \in \mathcal{C} = \mathcal{C}_{\mathcal{L}} \cup \mathcal{C}_{\mathcal{U}} (e.g., EMA entries within participants, students within schools). Define centered observation scores dic=(gi−λg̃i)−d‾ℒd_i^c = (g_i - \lambda \tilde{g}_i) - \bar{d}_{\mathcal{L}} and ujc=g̃ju−g̃‾𝒰u_j^c = \tilde{g}_j^u - \bar{\tilde{g}}_{\mathcal{U}}.

  • Disjoint cluster validation (𝒞ℒ∩𝒞𝒰=∅\mathcal{C}_{\mathcal{L}} \cap \mathcal{C}_{\mathcal{U}} = \emptyset): M̂disjoint=1n2GℒGℒ−1∑c∈𝒞ℒ(∑i∈ℒcdic)(∑i∈ℒcdic)⊤+λ2N2G𝒰G𝒰−1∑c∈𝒞𝒰(∑j∈𝒰cujc)(∑j∈𝒰cujc)⊤. \hat{M}_{\text{disjoint}} = \frac{1}{n^2}\frac{G_{\mathcal{L}}}{G_{\mathcal{L}} - 1}\sum_{c \in \mathcal{C}_{\mathcal{L}}} \left(\sum_{i \in \mathcal{L}_c} d_i^c\right)\!\left(\sum_{i \in \mathcal{L}_c} d_i^c\right)^\top + \frac{\lambda^2}{N^2}\frac{G_{\mathcal{U}}}{G_{\mathcal{U}} - 1}\sum_{c \in \mathcal{C}_{\mathcal{U}}} \left(\sum_{j \in \mathcal{U}_c} u_j^c\right)\!\left(\sum_{j \in \mathcal{U}_c} u_j^c\right)^\top.
  • Overlapping/within-cluster validation (𝒞ℒ∩𝒞𝒰≠∅\mathcal{C}_{\mathcal{L}} \cap \mathcal{C}_{\mathcal{U}} \neq \emptyset): Define unified cluster score Sc(λ)=1n∑i∈ℒcdic+λN∑j∈𝒰cujc=Ac−λBcS_c(\lambda) = \frac{1}{n}\sum_{i \in \mathcal{L}_c} d_i^c + \frac{\lambda}{N}\sum_{j \in \mathcal{U}_c} u_j^c = A_c - \lambda B_c. Since distinct clusters are independent, M̂shared=GG−1∑c∈𝒞Sc(λ)Sc(λ)⊤,λ̂cluster*=∑c∈𝒞(Ĥ−1Ac)⊤(Ĥ−1Bc)∑c∈𝒞∥Ĥ−1Bc∥22. \hat{M}_{\text{shared}} = \frac{G}{G - 1}\sum_{c \in \mathcal{C}} S_c(\lambda) S_c(\lambda)^\top, \qquad \hat{\lambda}^*_{\text{cluster}} = \frac{\sum_{c \in \mathcal{C}} (\hat{H}^{-1} A_c)^\top (\hat{H}^{-1} B_c)}{\sum_{c \in \mathcal{C}} \|\hat{H}^{-1} B_c\|_2^2}. This automatically captures within-cluster correlation between labeled and unlabeled entries from the same cluster.
  • Random-intercept multilevel extension (ppi_lmer()): Estimates random-intercept variance components (τ̂2,σ̂2)(\hat{\tau}^2, \hat{\sigma}^2) via lme4::lmer(), forms exact Woodbury GLS weights Vc−1=σ̂−2(Imc−τ̂2σ̂2+mcτ̂2𝟏𝟏⊤)V_c^{-1} = \hat{\sigma}^{-2}\big(I_{m_c} - \frac{\hat{\tau}^2}{\hat{\sigma}^2 + m_c\hat{\tau}^2}\mathbf{1}\mathbf{1}^\top\big), solves the GLS-weighted PPI++ estimating equations, and computes cluster-robust PPI++ sandwich standard errors alongside human-only and naive-LLM multilevel benchmarks.

2. Modular Package Architecture

llmmetric/
├── DESCRIPTION                 # Package metadata, lean Imports/Suggests
├── NAMESPACE                   # Generated via roxygen2
├── ARCHITECTURE.md             # Formal math & design blueprint (this file)
├── README.md                   # Overview, installation, quickstart examples
├── R/
│   ├── llmmetric-package.R     # Package-level docs & shared imports
│   ├── utils.R                 # Validation helpers, tidy formatting, math utilities
│   ├── schema.R                # coding_schema(), JSON Schema export, strict validation
│   ├── cache.R                 # coding_cache() content-addressed memory/disk cache
│   ├── backends.R              # backend_mock(), backend_openai(), backend_ollama()
│   ├── coding.R                # coding_design(), code_texts(), aggregate_scores()
│   ├── g_study.R               # g_study() REML + ANOVA multi-facet variance engine
│   ├── d_study.R               # d_study() reliability projections & target solver
│   ├── calibration.R           # calibration_metrics() continuous & categorical metrics
│   ├── drift.R                 # check_drift() temporal/version stability tests
│   ├── dpf.R                   # dpf_test() uniform/non-uniform & prompt-level DPF
│   ├── ppi_core.R              # Shared PPI/PPI++ data splitting, optimal lambda, sandwich core
│   ├── ppi_models.R            # ppi_mean(), ppi_lm(), ppi_glm() + S3 methods
│   ├── ppi_clustered.R         # ppi_clustered(), ppi_lmer() cluster/multilevel PPI++
│   ├── autoplot.R              # ggplot2::autoplot() S3 methods for all diagnostic objects
│   ├── simulate.R              # simulate_coding_study() synthetic study generator
│   └── data.R                  # Documentation for built-in dataset `ema_coded`
├── data/
│   └── ema_coded.rda           # Compact multi-facet EMA coding study dataset
├── tests/
│   ├── testthat.R
│   └── testthat/
│       ├── test-schema-cache.R
│       ├── test-backends-coding.R
│       ├── test-g-d-study.R
│       ├── test-calibration-drift.R
│       ├── test-dpf.R
│       ├── test-ppi-models.R
│       ├── test-ppi-clustered.R
│       ├── test-ppi-coverage.R # Monte Carlo 95% CI coverage proofs (biased/noisy LLMs)
│       └── test-autoplot.R
└── vignettes/
    ├── getting-started.Rmd     # End-to-end psychometric workflow
    └── ppi-coverage-proof.Rmd  # Monte Carlo proof: Naive LLM vs Human-Only vs PPI/PPI++

3. Core Design Invariants

  1. Dual-input ergonomics: Psychometric and inference functions accept both llm_coded_data objects produced by code_texts() and standard data.frame/tibble objects from external coding pipelines.
  2. Offline reproducibility: Every test, example, and vignette runs deterministically offline using backend_mock() and mockable HTTP transports for backend_openai() / backend_ollama().
  3. Zero global RNG pollution: backend_mock() derives deterministic per-cell hashes from (seed, unit_id, prompt_id, model, temperature, replicate) while preserving .Random.seed.
  4. CRAN hygiene: Zero writes to user home directories (caches default to in-memory or user-supplied paths), zero non-standard evaluation R CMD check notes, clean S3 print/summary/autoplot contracts.