Disclosure Risk and Data Utility Metrics for Synthetic and Anonymized Data
Overview
Provides comprehensive methods to measure disclosure risk and data utility for anonymized and synthetic data. Implements attribution-based risk metrics including Correct Attribution Probability (CAP), Targeted CAP (TCAP), Within Equivalence Class Attribution Probability (WEAP), and RAPID (Risk of Attribute Prediction-Induced Disclosure). Also provides distance-based privacy metrics such as Distance to Closest Record (DCR), Nearest Neighbor Distance Ratio (NNDR), and Identical Match Share (IMS). Utility assessment includes propensity score analysis, distribution comparisons, and various statistical tests. Methods are based on Taub et al. (2018) doi:10.1007/978-3-319-99771-1_9 and related literature. Designed for integration with 'simPop' S4 classes.
Bug fixes and one API addition, all surfaced while preparing the JSS software
paper. Three of these change reported values, so results produced with 0.1.0
are not directly comparable.
New
tcap()gainscont_bins(default 10), matchingdcap(). A continuous target is now discretised into quantile bins before matching. Previously an exact match on a continuous value essentially never occurred and every TCAP score collapsed to zero.tcap()now reports all three TCAP variants in use in the literature and gains akindargument ("certain", the default;"matched";"conditional") that selects which oneprint()/summary()highlight -- reported values are unchanged.tcap_certainkeeps riskutility's strict definition (the key uniquely determines the target in both the original and the synthetic data). The newtcap_matchedreproduces synthpop's TCAP as defined up to synthpop 1.9-2; the newtcap_conditionalimplements the definition of Little, Allmendinger & Elliot (2025, Journal of Official Statistics 41(1), 255-308), which synthpop adopts from version 1.9-3. The previous documentation claim thattcap_certainequals synthpop's TCAP held only on data where every disclosive synthetic key class is also unambiguous in the original data; the documentation now states the exact mapping.
Show all changes in 0.2.0Hide the rest of the changes in 0.2.0
Bug fixes (change reported values)
propscore(): the synthetic-side kernel density was indexed withlength(ps)-- a scalar -- rather thannrow(p), so the index ran backwards and every density diagnostic reported bysummary()(kl,density_ratio,mean_ratio,sd_ratioand their Bayes-space counterparts) was computed on the wrong records.tstr(): R-squared is now clamped at 0, and the TSTR/TRTR ratio is returned asNAwith a warning when the train-on-real model has no predictive power. Previously two negative R-squared values could divide to a large positive ratio and be reported as excellent utility.tail_fidelity(): the Jensen-Shannon divergence is now computed in density space. It previously used Bayes-space (clr) ordinates, which are sign-indefinite, and could return values far outside[0, log 2].
Other
dcr()now warns when the training and holdout sets differ in size. Thedcr_sharereference value of 0.5 and the 0.55 rule used byprivacy_passassume equal sizes; with an unequal split the expected share under no memorisation isn_train / (n_train + n_holdout).- Tests that compare riskutility against synthpop output are now version-aware (synthpop 1.9-3 redefines its TCAP measure) and are skipped on CRAN, as requested by the synthpop maintainers and the CRAN team. They continue to run in local
devtools::test()runs. print.tcap()no longer errors on a result with zero matched records.compare_feature_importance(importance_type = "permutation")no longer requires the vip package (archived from CRAN on 2026-07-08 and therefore flagged by the CRAN incoming checks): permutation importance is computed internally, and the documented caret-style metric names ("Accuracy","Kappa","ROC AUC","RMSE","MAE","MAPE","R-squared") as well as custom metric functions are handled directly, with error metrics sign-flipped so that larger importance always means a more influential feature. vip was removed fromSuggests.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK6 OK2026-06-23
Documentation
- Help pages
- 328 (43 internal)includes a package overview page
- Examples that run
- 89%75 run in a plain check · 9 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 93%
- Documented parameters
- 97%
- Return-value docs
- 100%
- Help pages citing references
- 16%
Downloads
Repository
Stars over time
Commits over time
2 development-tooling and community-health practices detected across 2 families in the upstream repository
Checks run against github.com/matthias-da/riskutility on 2026-10-18.
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-01-28Seen in the repository: CLAUDE.mdNamed in .Rbuildignore: .claude, CLAUDE.mdNamed in .gitignore: .claude, CLAUDE.mdCommits: at least 65 crediting it in the message
- Gemini CLIfirst seen on or before 2026-07-18Config: a file or ignore line, not recorded which
- Claude Opus 4.650 commits · Mar 2026
- Claude Sonnet 4.69 commits · Mar 2026
- Claude Opus 54 commits · Aug 2026
- Claude Fable 52 commits · Sep 2026
Dependencies
Installing riskutility adds 40 packages (26 with compiled code, 55 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, data.table 5.7 MB.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 0.2.0Latest
- 0.1.0first seen 2026-06-22
- RR 4.6.0 released · 2026-04-24
Package metadata
- First seen
- 2026-06-22
- Total releases
- 2 / 1 yrs
- License
- GPL-3 OSI
- Minimum R
- ≥ 4.1.0
- Download size
- 1.2 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("riskutility")The package provides a citation file, so citation() returns the authors' own entry.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.