Changelog
Source:NEWS.md
flexsynth 0.3.6
Bug fixes
- Bounded unordered categorical response cardinality (
> 20levels -> top 19 + catch-all during tree construction only) inctree_fit()to eliminate cubic covariance hangs inpartykit::ctree()on high-cardinality targets (vcd::Baseballname2), while still sampling full uncollapsed original values from terminal leaves. - Dropped unused factor response levels (
droplevels()) and checked effective class count before setting predictor collapsing limits incart_fit(), eliminatingrpart()C-level hangs when a 3+ level factor target has only<= 2observed levels in a training subset (caret::SacramentoStar schema) while preserving all declared factor levels in synthetic draws.
flexsynth 0.3.5
Bug fixes
- Pruned 1-level / constant factor predictors (such as upstream missingness
.na_*indicators on observed target rows or constant factors) viaprune_linear_predictors()beforestats::glm()/stats::model.matrix()acrossnorm,normrank,pmm,logreg,polyreg, andpoisson(including clean intercept-only/marginal fallback and unseen-level pruning for GLMs), eliminatingcontrasts can be applied only to factors with 2 or more levelserrors under mixed/parametric synthesis. - Added
drop = TRUEwhen grouping by unit/foreign-key identifiers insynth_skeleton(),synthesise_once_conditional(),apply_constraints(),dp_contribution_bound(),reconcile_sum_rules(), anddetect_monotone_temporal_cols()sofactoridentifiers carrying unused levels never create phantom empty blocks (replacement has 1 row, data has 0).
flexsynth 0.3.4
Bug fixes & improvements
- Fixed
subscript out of boundscrashes across all Track B DP engines (dp_fit_model(), adaptive/annealed, AIM, PGM reconciliation, GreedyBayes, longitudinal transitions/tensors, and cross-table linked fitters) whenever a child or constant/DP-set-union-collapsed column had a single bin (nbin == 1L): replacedt(apply(..., 1L, dp_normalise))dimension-dropping matrix transposes with a dimension-safedp_row_normalise()helper. - Extended DP set-union character category discovery (
domain = "dp",delta > 0) to longitudinal DP (synth(..., structure = ~ id / visit, privacy = dp_control(...))) with exact(epsilon, delta)composition accounting over shareddomain_frac, matching flat DP while keeping fail-closed guards fordomain = "public"anddelta = 0. - Fixed minor missing-space typography in
dp_classify_columns()category/type error messages.
flexsynth 0.3.3
Bug Fixes & Stability Hardening
Hardened
ctree_fit()/ctree_draw()againstpartykit::ctree()’s>= 31-level unordered split crash and combinatorial slowdown by collapsing high-cardinality unordered predictors viaprep_predictors(..., max_levels = 16L), dropping unused response factor levels before fitting, and adding a 1-class post-bootstrap short-circuit.Preserved the
"ordered"S3 class for ordered factors (both modelled columns and longitudinal structural indices) across Track B differentially private synthesis (dp_col_domain(),dp_decode_col(), anddp_index_as_position()).
flexsynth 0.3.2
Bug Fixes & Edge-Case Hardening
Enhanced
rel_fk(..., coherent_via = ...)insiderel_schema()to resolve either the intermediate parent table name or its foreign-key column name, and fail fast with an explicit error if an explicitcoherent_viadoes not match any empirically consistent transitive Diamond path.Enabled Track B linked DP (
synth_linked(..., privacy = dp_control(...))) when the root"entity"table references an immutable"lookup"dimension (e.g.,dim_patient -> dim_center) by promoting lookup-parented entity roots cleanly and preserving lookup key storage types.Silenced spurious
Dropped unused factor level(s) in dependent variablewarnings fromranger::ranger()insideforest_fit()when fitting on subsampled factor targets, while retaining full factor levels on synthetic output.
flexsynth 0.3.1
Bug Fixes & Stability Hardening
Fixed an
rpartcrash (number of rows of matrices must match) incart_fit()andfit_var()whenever a target column (including 1-level factors or longitudinal missingness indicators that are 100% observed at visit 1 and partially missing at follow-up visits, such as insurvival::pbcseq) has at most one unique non-missing value. Single-class targets now short-circuit cleanly without invoking classification tree splitting.Prevented exponential
2^(k - 1)split hangs inrpartwhen high-cardinality unordered categorical columns are used as predictors (including cross-table predictors in linked Snowflake/Star/Bridge schemas) by lumping rare tail levels into.flexsynth_otherinsideprep_predictors()and mapping unseen levels consistently atcart_apply()time.Fixed a spurious
invalid factor level, NA generatedwarning insidediagnose()(pmse_diagnostics()) when stacking real and synthetic frames whose factor columns (such as regeneratedfactorunit IDs) carry distinct level sets; temporal columns are also normalised prior torbind().
flexsynth 0.3.0
Star, Fan, Snowflake, Bridge & Diamond Relational Schemas
New declarative relational schema builder
rel_schema(), withrel_fk(),rule_sum(), andas_rel_schema()(supportingdmcoercion when installed).synth_linked()now supports 3NF surrogate primary keys, StarN:1multi-parent facts with immutable"lookup"dimensions and conditional assortative FK co-assignment, Snowflake multi-hop ancestor conditioning, associativeM:Nbridges, and deterministic Diamond foreign-key coherence.Fan schema chasm-trap fix (
rel_schema(..., sibling_bridge = "cluster")): bottom-up per-parent sibling count and cluster summaries preserve cross-sibling correlations and correlated child counts.rule_sum()enforces compositional parent-child sum conservation.Track B (DP)
synth_linked()now supportsrel_schemawith 0-sensitivity"lookup"dimensions, 3NF surrogate primary keys, and Diamond FK coherence.
Native Temporal & Chronological Synthesis
Native zero-conversion support for
Date,POSIXct(preservingtzone),POSIXlt,difftime(preservingunits),hms, andITimeacross Track A, Track B (DP),diagnose(), anddisclosure_risk().New
temporal_control()wired intosynth_control()automatically detects intra-row chronological chains (admit_date <= proc_date <= discharge_date), longitudinal monotone waiting times, parent-interval bounds ([0, 1]containment), cyclical calendar predictors, and empirical resolution quantum snapping.Track B (DP) fail-closed domain enforcement:
Date/POSIXct/difftime/hmscolumns are routed through accounted quantile/grid discretisation rather than unaccountedcharacterfallback, and unrecognised S3 classes fail closed underdomain = "public"/"dp".
Linked-Engine Parity, Methods & Multi-Table Inference
synth_linked()now supports MAR missingness indicators,count_model = "conditional"on child tables, auto-smoothing, and table-scopedrule(..., table = )constraints.method = "forest"now accelerates withrangerwhen installed (respecting_R_CHECK_LIMIT_CORES_thread caps) with baggedrpartfallback; added built-in"pmm","logreg","polyreg", and"poisson"methods.pool_synth()andcompare_estimates()now supportsynth_linked_result,diagnose()attachescross_tablechild-count summaries, anddisclosure_risk()supportsentity_join = TRUE.
flexsynth 0.2.1
CRAN release: 2026-09-02
Statistical and disclosure-risk corrections
Linked disclosure diagnostics now propagate a per-table holdout into each membership-inference analysis. Quasi-identifier row keys use collision-safe, length-prefixed encoding rather than delimiter concatenation.
TCAP now compares key-conditioned attribution with the marginal attacker on the same covered records. The previous all-record marginal remains available as
baseline_unconditional, and coverage / covered counts remain explicit.Logistic pMSE calibration now uses the fitted complete-case sample size and effective model rank. The correlation diagnostic now reports the true full-matrix Frobenius norm rather than the norm of one triangle.
Custom pooled-analysis variances are aligned by term name. Non-numeric, non-finite, negative, duplicated or mismatched estimate / variance contracts now fail explicitly, as do estimate comparisons with no common terms.
Documentation and release engineering
README, package metadata, vignettes and help now distinguish descriptive diagnostics from safety guarantees and published pooling rules from universal inferential validity. The supported structural scope and external governance checks for a differentially private release are stated explicitly.
Source builds exclude repository and check artifacts. Release metadata and CRAN helpers now target 0.2.1, and CI includes R-devel and oldrel-1 on Ubuntu in addition to release R on Ubuntu, macOS and Windows.
flexsynth 0.2.0
New features
Pooled inference from synthetic data.
pool_synth()fits an analysis on each of themsynthetic datasets and combines the results with a standard error that accounts for between-synthesis variation, which an analysis of a single synthetic dataset cannot estimate. Two fully-synthetic combining rules are provided (rule=): the large-sample synthpop estimators of Raab, Nowok & Dibben (2016) (default, matchingsynthpop::summary.fit.synds) and the classic Reiter (2003) estimator. The analysis may be any model withcoef()/vcov()methods or a plainlist(estimate=, variance=).synth_glm()is a convenience wrapper for the linear / generalised-linear case.population_inferencetoggles between population- and sample-level standard errors. Track B (DP) results are refused (DP inference must additionally account for the noise). Thesynth_resultnow records whetherpropersynthesis was used, which selects the correct variance formula.Missing-data model. A Track A variable that contains
NAs is now split into a companion missingness indicator — a factor synthesised in sequence just before the variable — plus the value itself, whose model is fitted on the observed rows only. Missing entries are placeholder-imputed for the variable’s role as a predictor so missingness never cascades into fully-observed downstream variables, and the synthesised indicator drives which rows are set back toNA. This preserves both the missingness rate and its association with the other variables (e.g. values missing more often for older subjects). The indicator columns are stripped from the returned data. Applies to single-table [synth()]; linked children and Track B are unchanged for now.Attribute-disclosure measure (TCAP).
disclosure_risk(..., target = )now reports the Target Correct Attribution Probability (Taub, Elliot et al.): how well an attacker who knows a record’s quasi-identifier keys can read a sensitivetargetoff the synthetic data, against a marginal-only baseline (lift= the excess). This is the governance-facing complement to the existing identity and membership measures. For a linked input it is assessed on the table that holds the target.Continuous variables are smoothed by default.
synth_control(smoothing)now defaults to auto: numeric variables that look continuous (more than 20 distinct values) are kernel-smoothed, so their CART draws are no longer confined to the observed values — improving marginal realism and reducing exact-value replication (an identity-disclosure vector). Low-cardinality numeric codes are left alone. This changes single-table [synth()] output versus 0.1.x; setsmoothing = FALSE(now accepted, along with"none") to restore the previous behaviour.TRUE/"density"still smooth every numeric column.DP longitudinal noise guidance.
synth_linked()withdp_control(longitudinal = ...)now warns when a child’s transition histogram will be swamped by the DP noise, so its within-unit autocorrelation would not survive. The transition sensitivity ispath_cap[parent] * (branching_cap - 1), so a deep hierarchy, a large branching cap, finebins, or a smallepsilonall inflate the noise; the warning names the table and points to the knobs (lowermax_rows_per_person, raiseepsilon, use fewer bins). The warning is a console diagnostic for the data holder and is never a released quantity.Specific-utility comparison.
compare_estimates()fits the same analysis on the real and synthetic data and reports, per term, the confidence-interval overlap (Karr et al.) and the standardised difference of the estimates — the analysis-specific “does my regression come out the same?” utility, complementing the general marginal / pMSE views ofdiagnose(). Pools a multi-dataset result.Categorical association view in
diagnose(). A Cramer’s V association-matrix comparison is now reported alongside the numeric correlation view, so dependence between factor variables is checked, not just numeric-numeric.Covariate-conditional row counts.
synth_control(count_model = "conditional")synthesises subject-level covariates first and draws each unit’s number of rows from a CART model of size on those covariates, so a dependence such as “sicker patients have more visits” is preserved."marginal"(default) keeps the previous covariate-independent size resampling. Takes effect only for nested data with subject-level covariates.
Bug fixes
-
method = "norm"/"normrank"no longer crash on missing data. The linear-model fit droppedNArows viamodel.matrix()while keeping the full-length response, causing"'qr' and 'y' must have the same number of rows". The fit now uses complete cases, and prediction propagates a missing value where a synthetic predictor is itself missing rather than erroring. (A dedicated missingness model remains future work.)
flexsynth 0.1.2
- Documentation:
?synth_linkedpreviously stated, as flat limitations, that under differential privacy (Track B) cross-table statistical conditioning “is not preserved” and within-table longitudinal structure “is not modelled”. That text predated thedp_control(cross_table = ...)anddp_control(longitudinal = ...)opt-ins, which do model both (parent-conditioned child variables and a within-unit DP Markov trajectory over a child’s repeated rows), and so understated the package. The roxygen now documents the default (own within-table marginals; exchangeable rows) and both opt-ins accurately. Behaviour is unchanged.
flexsynth 0.1.1
-
Bug fix:
method = "ctree"on a barecharactertarget. Thepartykitconditional-inference-tree method fitted the tree with the raw response column, which trippedpartykit:::.y2infl()with “unknown response class” whenever the synthesised column was a plaincharactervector (rpart-backedcarttolerated it, so this only surfaced underctree). The response is now coerced to a factor for the fit while draws still return the original values. This was caught by win-builder R-devel, wherepartykitis available and the guarded test actually runs. - Documentation: the README link to the roadmap now points at its GitHub URL (the
docs/directory is not shipped in the package), and aninst/WORDLISTrecords the intentional British spellings used in the DESCRIPTION.
flexsynth 0.1.0
First public release: a flexible sequential-synthesis engine for nested, longitudinal and linked multi-table data (Track A, high-utility default) with an opt-in differentially private track (Track B) providing a formal person-level (, ) guarantee. The notes below summarise what shipped.
Track B: DP set-union discovers
charactercategory sets underdomain = "dp". A barecharactercolumn no longer has to be pre-converted to afactor: under the defaultdomain = "dp", its present category set is discovered privately with a stability histogram — each present category’s count gets Laplace noise and is kept only if it clears a threshold that hides any category a single person could have created; rare/unique categories fold into an appended"(other)"catch-all. The cost is funded from the samedomain_fracslice that numeric bin-edge estimation uses, and composes into the exact (, ). Because a threshold cannot hide a lone category’s presence atdelta = 0, discovery needsdelta > 0; a pure- release still refusescharacter(pointing todelta > 0or publicfactorlevels). Flatsynth()only (linked / longitudinal still require public levels). New internaldp_discover_categories(); releases with nocharactercolumn are byte-identical to before.Track B: model-projection candidate scoring is now the Full AIM default.
dp_control(select = "aim")now scores each candidate marginal in AIM’s exponential-mechanism rounds against the current reconciled Private-PGM model’s own marginal over that pair (scoring = "model"), rather than the product of its one-way marginals — completing AIM’s actual quality function as the faithful default. A loopy pair the model already explains through the marginals measured so far no longer looks surprising, so the budget is steered to the genuinely worst-fit interaction instead of re-selecting one the model already fits. The model reference is read from the already-privatised marginals (reconciled each round and projected onto the candidate — a not-yet-measured pair projects across cliques of the junction tree, via the internaldp_pgm_project()), so it is pure post-processing: the exponential mechanism’s sensitivity and the exact (, ) are unchanged; only which marginals get selected changes. It costs a reconciliation per selection round and composes withanneal = TRUE. This can change the output of an existingselect = "aim"release (a different marginal set may be chosen); the previous one-way-product reference remains available as the cheaper opt-out viadp_control(select = "aim", scoring = "independence"). The new default is expressed throughscoring = "auto"(model for"aim", independence for every other selector). Flat-table only.Track B: annealed Full AIM.
dp_control(select = "aim", anneal = TRUE)runs Full AIM on the same data-adaptive -halving schedule thatselect = "adaptive"already offers, instead of the fixedmin(d(d-1)/2, treewidth·(d-1))rounds. Thedone-way marginals take a fair fixed share; the pairwise measurements and their exponential-mechanism selections start at a small per-round quantum (large noise) and double whenever a round’s measured signal fails to beat its noise floor. A baseline of treewidth-capped new loopy pairs is selected first, then any surplus budget re-measures the worst-fit already-measured pair (inverse-variance combined). The measurement and selection pools stay strictly proportional through every doubling and reserve, so they deplete in lockstep and the final round absorbs the exact remainder — the total spend is still exactly (, ), now over a variable number of rounds chosen from the data. As in the fixed-round case the annealed set is triangulated and reconciled with Private-PGM, so refinement sharpens loopy marginals (not just tree cliques). Flat-table only.Track B: Full AIM.
dp_control(select = "aim")lifts the running-intersection constraint on theselect = "adaptive"junction-tree selector, so the exponential mechanism may pick loopy marginals — a pairwise marginal between two variables already in the model, the cycle a junction-tree selector structurally cannot close (and that no tree captures at any budget). Because a loopy set has no forward junction-tree sampler, AIM reconciles the whole measured set (thedone-way marginals plus the selected pairs) into one graphical model over a triangulated junction tree via Private-PGM (belief propagation + entropic mirror descent) and samples from that — following McKenna et al.’s AIM. It runs a data-independentmin(d(d-1)/2, treewidth·(d-1))selection rounds, each rejecting any new pair whose triangulated clique would exceedtreewidth + 1(so the model’s treewidth is bounded and the inference stays exact); attreewidth = 1no loop can close, so it reduces to an adaptively-selected tree. Selection and measurement compose into exactly the same (, ) as any other flat slice, and the reconciliation is budget-neutral. Like"adaptive"it usestreewidth/select_frac(notstructure_frac/degree/anneal, which are refused), and is flat-table only (refused on longitudinal / linked releases).Track B: Private-PGM inference step.
dp_control(estimator = "pgm")adds the reconciliation the other (PGM-free) Track B samplers deliberately omit. Instead of using each measured marginal locally (the tree takes each edge’s raw noisy 2-way as and discards both the other one-way marginals and the disagreement between overlapping noisy marginals), it reconciles the whole measured set into the single graphical-model distribution that best fits all of it at once (least squares) — following McKenna et al.’s Private-PGM / MST — by belief propagation on a junction tree of the measured cliques plus entropic mirror descent, then samples from that. A tree (or the adaptive junction tree) has bounded treewidth, so the inference is exact and cheap. Reconciliation is pure post-processing of the already-privatised marginals, so it spends no extra budget: the (, ) is identical to the same release with"local"; only the fitted model changes. It denoises (overlapping marginals are made mutually consistent) and lets the otherwise-discarded one-way marginals constrain the model. Available for the flatdependence = "tree"release (degree-1) and forselect = "adaptive"; an alternative tostructure_frac,degree > 1andanneal = TRUE; refused on longitudinal / linked releases."local"(default) leaves every existing path byte-identical.Track B: PrivBayes degree>1 Bayesian networks.
dp_control(dependence = "tree", degree = k)generalises the Chow-Liu tree (a degree-1 Bayesian network) to GreedyBayes: a degree-knetwork in which each variable may condition on up tokof the already-generated variables. Each parent set is chosen greedily with the exponential mechanism, scored by the parentsnode association only (so a near-duplicate parent pair is not preferred over the parents a node truly depends on). Because a tree gives a variable a single parent, it cannot represent a variable that depends on two otherwise-unrelated predecessors (a v-structure, e.g.Ca noisy XOR of independentAandB); a degree-2 network takes both parents and recovers it. Construction measures thedone-way marginals plus one(parents, node)family joint per non-root node (2d - 1marginals) and spends aselect_fracslice on thed - 1greedy picks; every slice composes into the same exact (, ) (zCDP for Gaussian, pure for Laplace). The network is forward-sampled ancestrally, so like the tree it needs no PGM inference.degreeis capped tod - 1, shares thebins^(degree + 1)cell-count warning, is an alternative tostructure_fracandselect = "adaptive", and is refused on longitudinal / linked releases.degree = 1(default) leaves the Chow-Liu path byte-identical.Track B: AIM-style budget annealing and higher treewidth for adaptive selection.
dp_control(select = "adaptive")gainsanneal = TRUE, a data-adaptive round schedule in place of the fixedd - treewidthrounds. The one-way marginals take a fair fixed share; the clique measurements and their exponential-mechanism selections start at a small per-round quantum (large noise) and double whenever a round’s measured signal fails to beat its noise floor (AIM’s -halving rule). After the mandatoryd - treewidthspanning cliques (which keep every variable covered, so the sampler stays PGM-free) any surplus budget is spent on extra rounds that re-measure the worst-fit existing clique — inverse-variance combined, so / adds exactly. The final round absorbs the exact remainder, so the release is still exactly (, ) over a variable number of rounds. The accounting reports the realised schedule (rounds, spanning vs refinement, how often halved, and the noise range). Thetreewidthcap is also lifted:treewidth = 3now measures four-way cliques (interactions no three-way marginal can see, e.g. a 3-bit parity), with a warning when a clique’s cell count (bins^(treewidth + 1)) grows large enough that per-cell noise would dominate.anneal = FALSE(default) leaves the fixed-schedule adaptive path byte-identical.Track B: AIM-style adaptive marginal selection. New
dp_control(select = "adaptive", treewidth = w)opts a flatsynth()DP release out of measuring a predetermined marginal set. After the one-way marginals it grows the dependency model one marginal at a time, at each round using the exponential mechanism to privately pick the marginal the model-so-far fits worst, then measuring it. The selected cliques form a bounded-treewidth junction tree by construction, so the model is a rooted junction-tree sampler (no PGM/IPF inference):treewidth = 1is a spanning tree (equivalent model class todependence = "tree"),treewidth = 2measures three-way marginals that capture interactions a Chow-Liu tree structurally cannot. Selection and measurement each spend budget and compose exactly into the same (, ) — zCDP for Gaussian, pure for Laplace — with a data-independent round count (d - treewidth);select_fracsplits the marginal budget between the two. Unlikestructure_frac(which picks a tree from one free noisy scan), adaptive selection is model-error-guided and, attreewidth >= 2, escapes the tree’s expressiveness ceiling. Flat-table only (refused on longitudinal / linked releases);treewidthshipped for 1 and 2. The defaultselect = "fixed"leaves every existing path unchanged.Track B: a linked longitudinal child’s transitions can now condition on the parent. New
dp_control(transition_parent = p)re-injects the synthetic parent’s (subject-invariant) attributes into a longitudinally-modelled child’s transition tensor at every step, not just its initial state. Until nowcross_table = TRUEcross-conditioned only the child’s initial state; the parent’s influence then rode the own-lag chain and decayed. Withtransition_parent = p, each time-varying child column additionally conditions its next value on thepimmediate-parent attributes most strongly associated with it, so parent → child dependence stays anchored across the whole trajectory. The parents are chosen automatically and budget-neutrally from the parent-by-child joints the cross-conditioned initial state already measures — so it adds no histogram and no sensitivity (a transition tuple still lands in one cell), and the (, ) accounting is unchanged. Because it reuses those joints,transition_parent > 0requirescross_table = TRUEfor that child (an error is raised otherwise). It composes withbaseline,transition_orderandtransition_cross. Linked-only (a flat longitudinalsynth()has no parent); ignored by non-longitudinal children.Track B: baseline columns and deeper transitions now apply to a linked longitudinal child. The two within-unit transition controls of the flat DP Markov engine —
dp_control(baseline = ...)(subject-invariant columns held exactly constant within a unit) anddp_control(transition_order = k, transition_cross = m)(each time-varying column steps on its own lastkvalues plus the lag-1 values of itsmmost associated companions) — are now honoured by any longitudinally-modelled linked child (synth_linked(..., privacy = dp_control(longitudinal = ...))), applied per table: a baseline name is matched against each such child’s own columns, and the order/cross settings apply uniformly to every longitudinal child. The budget stays exact — a baseline column drops its transition histogram (sharpening the rest), cross-conditioning is budget-neutral, and a higher order lowers the child’s transition sensitivity topath_cap[parent] * (branching_cap - order)(so the order must be at most one less than the child’s branching cap, validated per table). All three compose with the existing combined cross-table + longitudinal path (a cross-conditioned initial state can also hold baseline columns and step deepened transitions). Ignored by non-longitudinal linked children, exactly as before.Track B: cross-table conditioning and longitudinal transitions now combine on the same linked child. Previously a longitudinally-modelled child table (
dp_control(longitudinal = ...)) could not also be cross-conditioned on its parent —longitudinalsilently won. Now settingcross_table = TRUEalongside a longitudinal model on the same table cross-conditions that table’s initial-state model on the synthetic parent (the first row of each unit draws from a parent-conditioned Chow-Liu tree), and the within-unit transition chain then carries that parent dependence across the whole trajectory. The parent shapes where a trajectory starts; the transitions stay parent-free, so the only extra cost is thenC * nPparent-by-child initial-state joints, measured at the same first-row sensitivity as the initial marginals and folded into the same exact (, ) composition. A non-longitudinal child still cross-conditions all its rows exactly as before, and setting neither flag is unchanged.Track B: higher-order and cross-variable DP transitions. The flat DP Markov longitudinal engine can now condition a variable’s next value on more than its own single previous value.
dp_control(transition_order = k)uses the lastkof a variable’s own values (), anddp_control(transition_cross = m)additionally conditions on the lag-1 values of themmost strongly associated other variables, selected automatically and budget-neutrally from the pairwise marginals the Chow-Liu tree already measures (sotransition_cross > 0requiresdependence = "tree"). Each variable’s whole transition model is measured as one conditional tensor; early rows (before positionk + 1) are generated by marginalising that same tensor, which is post-processing and costs no budget. Extra conditioning columns do not change the (, ) budget — a transition tuple still lands in one cell — while a higher order lowers the transition sensitivity tocap - order(a person contributes fewer, deeper tuples), so composition stays exact and the order must be at mostmax_rows_per_person - 1.transition_order = 1,transition_cross = 0(defaults) keep the first-order own-lag model unchanged. (These also apply to a longitudinal linked child — see the top entry.)Track B: baseline columns held exactly constant.
dp_control(baseline = c(...))names subject-invariant columns in a longitudinalsynth()release (astructurewith a nesting index). Those columns are modelled once in the initial-state model — so their joint distribution and their correlation with the first visit are preserved — and then broadcast unchanged to every row of a synthetic unit, instead of being stepped through a transition matrix that would let a baseline covariate drift across visits. Because a baseline column carries no transition histogram, declaring it also removes that histogram from the release, so the remaining measurements are sharper at the same exact (, ). Declaring a column baseline is public schema knowledge and costs no budget; names that match no modelled column are ignored.baseline = NULL(default) treats every column as time-varying. (Also applies to a longitudinal linked child — see the top entry.)Track B: budget-efficient structure learning.
dp_control(structure_frac = f)learns the flatdependence = "tree"Chow-Liu structure from a cheap all-pairs scan that spends only the fractionfof the marginal budget, then concentrates the remaining1 - fon re-measuring only the chosen tree’s edges (plus thedone-way marginals). The previous single-pass fitter measured all pairwise marginals at full fidelity and discarded all but the tree’s edges; because structure selection tolerates noise far better than the parameters do, moving the bulk of the budget onto the retained edges sharpens the conditionals — increasingly so as the number of variables grows. Both passes compose into the same exact (, ) budget (the cheap scan and the concentrated re-measurement are two sequential releases whose pure- adds / zCDP adds).structure_frac = NULL(default) keeps the single-pass behaviour; the knob is inert fordependence = "independent", for fewer than three variables, and for longitudinal / linked DP releases.Track B: linked + longitudinal DP.
dp_control(longitudinal = TRUE)— or a character vector of child-table names — makes a linked DP release model a child table’s repeated rows as a within-unit time series instead of exchangeable records. For such a table the children-per-parent count model doubles as a trajectory-length model, an initial-state model is measured over each parent unit’s first (temporally earliest) child row, and a first-order Markov transition matrix is measured per variable over consecutive within-unit rows (ordered by the child’s own key index). Their person-sensitivities differ — initial marginals at the parent’s path cap, transitions atpath_cap[parent] * (branching_cap - 1)— and fold into the same exactly-composed (, ) budget as the rest of the release; over-cap units are prefix-truncated in temporal order so consecutive pairs stay intact. This recovers within-unit autocorrelation (a patient’s values trending across visits) that the exchangeable model drops. A longitudinally modelled table is not simultaneouslycross_table-conditioned;longitudinal = FALSE(default) is unchanged, and the flag is inert for flat / longitudinalsynth()releases (which pick the DP Markov engine from thestructureformula).Track B: cross-table conditioning under DP.
dp_control(cross_table = TRUE)makes a linked DP release model each child table’s variables on the synthetic parent’s attributes, not just link to it. For every child table with a modellable immediate parent, parent-by-child joint marginals are measured at the child grain — one observation per child row, at the parent’s value carried down the foreign key — so their person-sensitivity is the child’s per-entity path cap, identical to a child one-way marginal, and they fold into the same exactly-composed (, ) budget. The parent variables enter the child’s Chow-Liu structure as fixed context nodes (a seeded maximum-weight spanning tree), so each child variable’s single strongest predictor may be a parent variable or another child variable; underdependence = "independent"each child variable conditions on its single best parent variable only. At generation the synthetic parent’s already-drawn value conditions the child draw, and a three-level hierarchy chains it (a grandchild conditions on its already-conditioned parent). This preserves genuine cross-table statistical dependence — the association the first linked-DP release dropped — at the cost of the extra joints’ share of budget.cross_table = FALSE(default) is unchanged; the flag is inert for flat / longitudinalsynth()releases, which have no parent table.Track B: linked multi-table DP.
synth_linked()now accepts adp_control(), producing a differentially private release across a whole key hierarchy at once. The privacy unit is the root entity: adding or removing one individual — its root row and all the descendant rows that cascade from it — changes the release within a formal (, ) budget. Contribution is bounded hierarchically;max_rows_per_personis reused as the maximum children kept per parent for each child table (a single integer for all child tables, or a named list keyed by table name), the root cap being 1. Capping top-down bounds each entity’s per-table row count to a path cap (the product of branching caps from the root). Each table’s variable marginals and a children-per-parent count histogram are measured under one exactly-composed budget: the summed L1 (Laplace) and summed squared L2 (Gaussian zCDP) sensitivities add over every histogram, each scaled by its per-entity path cap (variable marginals) or the parent’s path cap (count histograms). Numeric bin edges are DP-estimated per table (domain = "dp") at the same per-table sensitivity, sharing thedomain_fracslice. Generation is parent-first and copies each synthetic parent’s surrogate key down as the foreign key, so referential integrity holds by construction (check_linkage()confirms it) at no privacy cost. First-version limitations: child variables are modelled by their own within-table marginals (cross-table statistical conditioning is not preserved under DP — only referential integrity), within-table longitudinal structure is not modelled for a linked table, and constraints /unit = "row"are refused.dp_control(max_rows_per_person = ...)now also accepts a named vector/list of per-table caps.Track B: longitudinal DP (a DP Markov model). When the
structuredeclares a nesting index (synth(data, ~ id / visit, privacy = dp_control(...))), the differentially private engine now preserves within-unit temporal structure instead of flattening to a surrogate id. It is the private analogue of Track A’s initial-state + lag-1 transition model: under one composed budget it measures a length histogram (rows per person), the initial-state one-/two-way marginals (thet = 1row), and a transition matrix per variable, then draws a length, an initial row and steps the transitions — so autocorrelation across visits survives the noise. Because a person contributes a whole trajectory,max_rows_per_personmust be set to the public maximum number of visits (>= 2); it caps each person’s effect on the transition histograms (a length- trajectory has at most consecutive pairs). The composition is exact: total L1 sensitivity (Laplace) and summed squared L2 (Gaussian zCDP), so the reported (, ) still holds end to end and the accounting print breaks the budget down (length + initial + transition). DP-estimated bin edges (domain = "dp") compose in as before. The synthetic nesting index is regenerated as the within-person position. Two first-cut limitations: every non-index column is modelled as time-varying (a constant baseline may drift a little between a synthetic person’s visits) and transitions are per-variable. Flat~ idDP releases are unchanged.Track B: rigorous, accounted discretisation. DP bin edges are no longer read silently from the data range.
dp_control()gains adomainargument (default"dp"): numeric variables without a public range inboundsnow have their edges estimated under differential privacy (a clamp-free exponential-mechanism quantile at each end), with the cost composed into the reported (, ) via adomain_fracbudget slice (default 10%).domain = "public"requiresboundsfor every numeric variable and spends no budget on the domain;domain = "data"keeps the old, warned, unaccounted behaviour for benchmarking only. In the rigorous modes a barecharactercolumn is refused (pass categoricals asfactor/logical, whose levels are public). The accounting record and its print method now report how the edges were chosen and what they cost. This closes the one data-dependent step previously excluded from the DP accounting.Phase 0 scaffold: package skeleton, MIT license, and CI (
R-CMD-check).Public API with settled signatures and input validation:
synth(),synth_linked(),synth_control(),dp_control().Two-track privacy design documented: high-utility default (Track A) and an opt-in person-level differentially private track (Track B).
Synthetic cardiac example-data generator (
data-raw/make_toy_cardiac.R).Phase 1 — single-table Track A engine.
synth()now returns real synthetic data (asynth_result) via sequential conditional synthesis:method = "cart"(leaf conditional bootstrap) andmethod = "sample". The unit identifier is regenerated by subject bootstrap; subject-invariant baseline columns are synthesised once per unit and broadcast;visit_sequence, per-variable methods, andpropersynthesis are honoured. Addedas.data.frame()/print()methods forsynth_result.Phase 2 — nested / longitudinal support. The synthetic skeleton is now drawn from an explicit learned rows-per-unit count distribution (rather than copying whole real units). Time-varying columns are synthesised with an initial-state model plus a Markov transition model that conditions on the previous row within the unit (lag-1 predictors of every time-varying variable), so within-unit autocorrelation across visits is preserved. Units of unequal length are supported; the flat and subject-baseline behaviour from Phase 1 is unchanged.
Phase 3 — linked multi-table engine.
synth_linked()now returns real synthetic tables (asynth_linked_result). The table hierarchy is read from thekeys; root tables are synthesised with the single-table engine and each child table is generated from its synthetic parent. Foreign keys are copied from the parent so they always resolve (referential integrity); the number of child rows per parent is drawn from a learned count distribution that includes parents with no children; the child’s own index is regenerated; and child variables are conditioned on the parent’s synthesised attributes (cross-table predictors), the own index and earlier child variables. Addedcheck_linkage()to verify key uniqueness and the absence of orphan child rows, plusas.list()/print()methods forsynth_linked_result.-
Phase 4 — methods, constraints and tuning.
-
Method registry. Synthesis methods are now an extensible registry. Built-ins:
sample,cart,forest(a bagged CART ensemble, no extra dependency),ctree(conditional-inference trees, viapartykit), and the parametric numeric methodsnormandnormrank(rank-preserving).register_method()adds custom methods by name;list_methods()lists them. Numeric-only / categorical-only methods are validated against the target type. -
Constraints / temporal logic.
rule()declares a logical constraint, either row-wise (rule(dbp <= sbp)) or per unit for temporal logic (rule(all(diff(los) >= 0), scope = "unit")).synth()enforces constraints by rejection sampling at the unit grain, so nested structure is preserved;constraint_max_triesbounds the effort. -
synth_control()wired end to end.smoothingkernel-smooths numeric draws (all numeric, or named variables);predictor_matrixrestricts which variables may predict each target;foresthyperparameters (ntree,mtry) are honoured.
-
Method registry. Synthesis methods are now an extensible registry. Built-ins:
-
Phase 5 — diagnostics, utility and disclosure risk.
-
diagnose(). Utility diagnostics comparing synthetic to real data: per-variable marginal fit (Kolmogorov-Smirnov for numeric, total-variation distance for categorical), the difference between the real and synthetic correlation matrices, and a general propensity-score utility (pMSE) with a null-expectation ratio (~1 when the two are indistinguishable). A base-graphicsplot()method overlays each marginal, and bothdiagnose()anddisclosure_risk()dispatch over a named list of tables (or asynth_linked_result). -
disclosure_risk(). Empirical privacy diagnostics: replicated uniques (real records unique on the quasi-identifiers and reproduced exactly), distance to closest record with a real-to-real baseline, and — given aholdoutof non-training records — a membership-inference check reporting an AUC and attacker advantage. Synthetic data is not anonymisation; these make residual risk visible. -
Vignettes. Three vignettes (getting started, nested / longitudinal, and multi-table linked cardiac), built pandoc-free with
litedown.
-
-
Phase 6 — performance and extensibility.
-
data.table fast-path. When the Suggested
data.tablepackage is installed, the synthetic skeleton and the constraint-filtered unit set are row-bound withdata.table::rbindlistinstead of repeateddo.call(rbind, ...), avoiding the quadratic cost of assembling thousands of one-unit blocks. Behaviour is identical withoutdata.table; only speed changes. Subject-invariant column detection is now a single vectorised pass rather than a per-columntapply()loop. -
Parallel replicates.
synth_control(parallel = ...)is wired end to end:TRUEuses all available workers and a positive integer sets an explicit count. Themindependent synthetic replicates are spread over a PSOCK cluster in bothsynth()andsynth_linked(), with independent L’Ecuyer RNG streams so a parallel run is reproducible for a fixed (seed, worker count). Serial synthesis (the default) is unchanged, and the engine falls back to serial if a cluster cannot be started.
-
data.table fast-path. When the Suggested
-
Phase 7 — Track B differential privacy.
synth(privacy = dp_control(...))now performs differentially private synthesis with a formal (, ) guarantee at person level. The engine is a marginal-based synthesiser in the PrivBayes / MST lineage: each person’s contribution is bounded (max_rows_per_person), numeric variables are discretised to a public grid, low-order marginals are measured under the chosen noise mechanism with correct budget composition, and synthetic records are drawn from the fitted model.-
Mechanisms and accounting.
mechanism = "laplace"gives pure -DP;"gaussian"gives approximate DP composed via zero-concentrated DP and calibrated to spend exactly (, ). Every result carries adp_accountingrecord (mechanism, composed budget, per-cell noise, contribution bound) for the release file. -
Dependence structure.
dependence = "tree"(default) learns a Chow-Liu tree from the same noisy marginals (no extra budget), retaining pairwise correlations;"independent"keeps only one-way marginals. -
Honesty about scope. DP mode is a flat / single-table release: it does not preserve within-unit longitudinal structure,
synth_linked()DP is not available yet, andrule()constraints are refused under DP (their data-dependent rejection would leak). Bin edges / category sets default to the data range with a warning unless supplied publicly viabounds; that step is excluded from the (, ) accounting. Seevignette("differential-privacy").
-
Mechanisms and accounting.
Phase 8 — polish. Documentation and release preparation, no behaviour change. The README now reflects the finished engine (Phases 1-7) with runnable examples and CI / lifecycle / license badges; a grouped
pkgdownreference index (_pkgdown.yml) andcran-comments.mdwere added; the package-level help now points tovignette("differential-privacy")instead of internal developer notes. StandardR CMD checkis clean (0 errors / 0 warnings / 0 notes) with all four vignettes built.