Skip to content

phontrast

2.5.0Package record

Contrast and Separation Metrics for Phonological Categories

0packages depend
926downloads / year
86.9%test coverage
13/13flavors OK

Overview

About

Computes and compares multiple measures of separation and overlap between phonological categories (for example vowels or consonants) in arbitrary multi-dimensional acoustic spaces such as formant values, mel-frequency cepstral coefficients (MFCCs), duration, or learned embeddings. The main entry point, phontrast(), reports several contrast metrics in one call -- Jensen-Shannon divergence and distance (Lin, 1991) doi:10.1109/18.61115, the Pillai-Bartlett trace, Bhattacharyya distance and affinity, Mahalanobis distance, and proportional overlap -- globally or by group on a common separation-oriented scale, with bootstrap confidence intervals. rank_contrasts() implements a measurement protocol for ranking speakers' contrasts by Jensen-Shannon distance and checking the ranking against Pillai, with sample-size licensing and a bandwidth-sensitivity check. Also provides utilities for preparing estimates for downstream modelling such as generalized additive models and mixed-effects models. Formerly released as 'phonJSD'.

Changes in 2.5.0

The ranking protocol in one call

This release implements the measurement protocol recommended by the simulation

study "Estimand or estimator? Comparing vowel overlap measures against a known

ground truth" (Berry, under review, Sec. VII.A), so that its three steps and

their conditions can be run and reported without hand-assembling them.

  • rank_contrasts(data, features, category_col, group_col) computes, per speaker, Jensen-Shannon distance (sqrt_jsd) and shared probability mass from one shared kernel density estimate and the Pillai trace on the same tokens (step 1); ranks the speakers on the percentile-rank scale (average rank - 1/2) / k, ties averaged, after setting measurements at the sqrt(JSD) ceiling (default 0.99) apart (step 2); and flags speakers whose Pillai and sqrt(JSD) percentile ranks differ by margin (default 0.25 of the ordering) or more (step 3).
Show all changes in 2.5.0Hide the rest of the changes in 2.5.0
  • The study's conditions are applied and reported rather than left to the user: sample-size floors per speaker from the smaller category's count (rank_licensed, flag_licensed, rank_basis; ranking licensed from 50 tokens per category at d = 2, 200 at d = 3-4, 500 at d = 5-8; the flag readable from 100 at d = 2 and 200 at d = 3-4, undefined when d >= 2n, withheld from d = 5), a warning below eight speakers, and the bandwidth check (sqrt(JSD) recomputed at half and twice the diagonal Scott bandwidth; bw_shift, sign_change, set_aside).
  • The result is a phontrast_ranking tibble with a print() method that summarizes the protocol, the estimator, the floors, the flagged and set-aside speakers, and the ceiling. The cleaned tokens travel with it in attr(x, "protocol").
  • plot_rank_agreement() (also plot() / ggplot2::autoplot() on the ranking) draws Pillai percentile rank against sqrt(JSD) percentile rank with the identity line and the +/- margin inspection band; flagged speakers are coloured and labelled, set-aside speakers crossed, unreadable flags hollow, and ceiling speakers listed in the caption.
  • inspect_contrast(ranking, group) redraws one speaker with plot_contrast()'s distribution-aware layers at half, the selected, and twice the diagonal Scott bandwidth, annotating each panel with sqrt(JSD) and shared mass at that bandwidth plus the speaker's Pillai, and restating the reported ranks and the bandwidth-check outcome in the subtitle.
  • Helpers: percentile_rank() (the protocol's rank scale, with an exclude mask), protocol_floors(d) (the licensing floors by dimensionality), and recommended_estimator(d) (the kernel estimator settings the study used at each dimensionality: plug-in / ks at d <= 4, diagonal Scott / fast_diag with 200 evaluation tokens from d = 5, no leave-one-out from d = 14).
  • A bundled, simulated twelve-speaker cohort, vowel_cohort, with a planted Pillai / sqrt(JSD) disagreement, a ceiling speaker, and two under-sampled speakers; and a vignette, "Ranking speakers by Jensen-Shannon distance and checking Pillai agreement", that walks through the protocol on it.

Bandwidth multiplier

  • New bw_scale argument on the kernel path (jsd_kde_nd(), percent_overlap_kde(), estimate_jsd(), estimate_overlap(), phontrast(), plot_contrast()): a positive multiplier on the selected bandwidth on the standard-deviation scale (h * bw_scale; bandwidth matrices H * bw_scale^2). 0.5 and 2 give the halved and doubled bandwidths of the smoothing-sensitivity check. plot_contrast() draws its regions, overlap shading, and annotations at the scaled bandwidth and records it in the caption. Ignored under density = "mvnorm".

The kernel family on one shared density

  • phontrast() now reads Jensen-Shannon divergence and distance, proportional overlap, total variation, and the matched-kernel Bhattacharyya affinity / distance and Hellinger distance off a single density estimate per comparison, instead of separate kernel passes for JSD and overlap. Values of the existing columns are unchanged; bootstraps do half the kernel work.
  • New opt-in metrics for phontrast(metrics = ...): "tv" (total variation, total_variation = 1 - percent_overlap); "bhattacharyya_kde" (bhatt_kde_dist, bhatt_kde_affinity, hellinger), the same quantity as the closed-form Gaussian "bhattacharyya" columns under a matched kernel estimator, with the same partial leave-one-out self-density as JSD, so measure and estimator can be told apart; and "euclidean" (euclidean_dist), the distance between the category means after dividing each feature by the pooled two-category standard deviation (bounded by 2 * sqrt(d) for equal category sizes). The default metric set and the column order of earlier releases are unchanged; long output and bootstraps cover the new columns.

Citation

  • citation("phontrast") now lists the study behind the protocol as a second entry (manuscript under review, with the OSF replication package), after the software citation.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 7.0 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OKNow
  • OK7 OK2026-08-10
Advisories

none known

Documentation

In release 2.5.0
READMEYes · 2,184 wordsVignettesYes · 3 · evaluation depends on the environmentNEWSYes · 100% structured · mentions 2.5.0Citation fileYes · cites a publicationWebsitenot declared in DESCRIPTION
Help pages
39 (2 internal)includes a package overview page
Examples that run
100%21 run in a plain check (3 of them under a condition)
Exported functions with examples
54%
Documented parameters
91%
Return-value docs
100%
Help pages citing references
3%

Downloads

926
CRAN downloads in the past year
Rank #11,861 · ~3/day · ~77/mo
Daily download trend is not available in this view yet.
33630 days
92690 days
9261 year
Compare downloads with other packages →
Also on30 r2u2 autocran

Repository

1Stars
0Forks
0Open issues
0Open PRs
14Releases
97Commits
3Commit identities
97 commits · Last activity 2026-10-08 · Default branch at 2.5.1, ahead of CRAN 2.5.0 (checked 2026-10-22)
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
0
Median days to close, 50 most recently updated closed PRs
0

Releases over time

2026-08-10 · 112026-10-08 · 14
PracticesBeta

6 development-tooling and community-health practices detected across 4 families in the upstream repository

Checks run against github.com/berrygrant/phontrast on 2026-10-22.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux

Reproducibility and dev environment (1)
data-raw/
CRAN release process (2)
cran-comments.mdCRAN-SUBMISSION
Research and citation (1)
CITATION.cff
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-07-18
    Pull request it wrote: opened by a project member
    Commits: 1 by its own account · at least 6 crediting it in the message
Models named in its commits
  • Claude Opus 4.83 commits · Jul 2026
  • Claude Opus 5.53 commits · Oct 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
11 external dependencies (excludes base and recommended)

Installing phontrast adds 25 packages (18 with compiled code, 13 MB of source tarballs). Heaviest: mclust 2.7 MB, Rcpp 1.8 MB, kernlab 1.0 MB.

Depends (1)
R >= 4.1.0
Imports (8)
ksdplyrpurrrtibblerlangstatsgrDevicesutils
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

Datasets

People & History

People (1)
Author, Maintainer since 2.3.1 (2026)
Listed in earlier versions (1)
Grant M.
no longer listed · 2.3.1 to 2.5.0
Releases (4)

Pick two releases to compare their code metrics.

  • 2.5.0Latest
    record
    2026-10-07 · current release · diff ↗ ·
    added 6 exports
    inspect_contrast, percentile_rank, plot_rank_agreement, protocol_floors, rank_contrasts, recommended_estimator
  • 2.4.1
    record
    2026-09-01 · diff ↗
  • 2.4.0
    record
    2026-08-09 · diff ↗
  • 2.3.1
    record
    2026-08-09
  • R
    R 4.6.0 released · 2026-04-24

Package metadata

First published
2026-08-09
Total releases
4 / 1 yrs
License
MIT + file LICENSE OSI
Minimum R
≥ 4.1.0
Bundled data
9.3 KB / 1 file
Download size
464 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("phontrast")

The package provides a citation file that builds its entry when R runs it. Run citation() to see it.

The repository also keeps a CITATION.cff.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for phontrast version 2.5.0 [Data set]. HJJB, LLC. Data release v2026-10-24. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy