| Title: | Local Differential Privacy Tools for Distributional Inference |
|---|---|
| Description: | Estimates cumulative distribution functions and quantiles under local differential privacy. Provides binary and categorical randomization mechanisms, isotonic distribution estimators, and simulation interfaces for sequential quantile estimation with self-normalized inference and asymptotic confidence sequences. Distribution estimators operate on privatized reports; quantile interfaces simulate local randomization internally. Methods include the quantile procedure of Liu et al. (2023) <https://proceedings.mlr.press/v202/liu23q.html> and the distribution estimator of Liu, Hu and Kong (2024) <https://proceedings.mlr.press/v235/liu24z.html>. |
| Authors: | Yi Liu [aut, cre], Qirui Hu [aut] |
| Maintainer: | Yi Liu <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-10-13 23:43:13 UTC |
| Source: | https://github.com/cran/ldpdist |
Estimation of cumulative distribution functions and quantiles under local differential privacy, with binary and categorical randomization mechanisms and methods for statistical inference.
For distribution functions, ldp_mechanism() and ldp_design()
specify the randomization mechanism and threshold design.
ldp_randomize() generates privatized reports, which are passed to
ldp_estimate_cdf() or ldp_estimate_category_cdf().
The quantile functions ldp_estimate_quantile(),
ldp_estimate_quantiles(), and ldp_estimate_quantile_cs()
are simulation interfaces: they receive a numeric data vector and carry out
the sequential local randomization internally. They do not implement a
distributed client-server service.
Randomization uses a secure byte source by default. On Windows this requires
the suggested openssl package. Seeded pseudo-random generation is
available for reproducible simulations through rng = "pseudo".
Liu, Y., Hu, Q., Ding, L. and Kong, L. (2023). Online Local Differential Private Quantile Inference via Self-normalization. Proceedings of Machine Learning Research, 202, 21698–21714. https://proceedings.mlr.press/v202/liu23q.html
Liu, Y., Hu, Q. and Kong, L. (2024). Tuning-free Estimation and Inference of Cumulative Distribution Function under Local Differential Privacy. Proceedings of Machine Learning Research, 235, 31147–31164. https://proceedings.mlr.press/v235/liu24z.html
Aggregates independent survey-level CDF estimates. The theory-motivated rule
uses weights proportional to n_s^(2/3) g_s(x0)^(2/3), where n_s
is the survey size and g_s(x0) is the threshold design density at the
target point.
ldp_aggregate_surveys( fits, x0, weights = c("equal", "theory", "sample_size", "custom"), design_density = NULL, custom_weights = NULL )ldp_aggregate_surveys( fits, x0, weights = c("equal", "theory", "sample_size", "custom"), design_density = NULL, custom_weights = NULL )
fits |
A nonempty list of |
x0 |
Point at which to aggregate CDF estimates. |
weights |
Weighting rule. |
design_density |
Positive threshold design density values at |
custom_weights |
User-supplied nonnegative weights for
|
An object of class ldp_survey_aggregate.
set.seed(1) mech <- ldp_mechanism("binary_rr", epsilon = 2) d <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) r1 <- ldp_randomize(stats::runif(100), mech, d, rng = "pseudo", seed = 1) r2 <- ldp_randomize(stats::runif(100), mech, d, rng = "pseudo", seed = 2) f1 <- ldp_estimate_cdf(r1) f2 <- ldp_estimate_cdf(r2) ldp_aggregate_surveys(list(f1, f2), x0 = 0.5)set.seed(1) mech <- ldp_mechanism("binary_rr", epsilon = 2) d <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) r1 <- ldp_randomize(stats::runif(100), mech, d, rng = "pseudo", seed = 1) r2 <- ldp_randomize(stats::runif(100), mech, d, rng = "pseudo", seed = 2) f1 <- ldp_estimate_cdf(r1) f2 <- ldp_estimate_cdf(r2) ldp_aggregate_surveys(list(f1, f2), x0 = 0.5)
Computes category-specific probability mass over (lower, upper] from
fitted category sub-CDFs. With conditional = TRUE, the output estimates
category probabilities conditional on the value falling in the requested range.
An error is returned when the fitted range mass is zero.
ldp_category_range_probability(object, lower = NULL, upper = NULL, conditional = TRUE)ldp_category_range_probability(object, lower = NULL, upper = NULL, conditional = TRUE)
object |
An |
lower, upper
|
Finite range endpoints within the fitted threshold range.
|
conditional |
Whether to normalize category masses by the total recovered mass in the range. |
A data frame with category probabilities. Attributes include
range_total and conditional.
set.seed(1) x <- stats::runif(100) y <- sample(c("A", "B"), 100, replace = TRUE) design <- ldp_design("category_cdf", grid = seq(0, 1, length.out = 11), categories = c("A", "B"), y = y) mech <- ldp_mechanism("uldp_censor", epsilon = 2, domain_size = 2) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 1) fit <- ldp_estimate_category_cdf(reports) ldp_category_range_probability(fit, lower = 0.25, upper = 0.75)set.seed(1) x <- stats::runif(100) y <- sample(c("A", "B"), 100, replace = TRUE) design <- ldp_design("category_cdf", grid = seq(0, 1, length.out = 11), categories = c("A", "B"), y = y) mech <- ldp_mechanism("uldp_censor", epsilon = 2, domain_size = 2) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 1) fit <- ldp_estimate_category_cdf(reports) ldp_category_range_probability(fit, lower = 0.25, upper = 0.75)
Computes the finite-grid pointwise variance induced by binary randomized
response and the public threshold design. For isotonic CDF fits, the formula
uses the affine randomized-response inverse and aggregates either observed or
planned threshold sample sizes over active PAVA pools. Planned allocation is
unavailable when report thresholds override the design. For divide-and-conquer fits, it returns the
block-studentized variance used by confint().
ldp_cdf_variance( object, newdata = NULL, source = c("observed", "planned"), as_matrix = FALSE )ldp_cdf_variance( object, newdata = NULL, source = c("observed", "planned"), as_matrix = FALSE )
object |
An |
newdata |
Optional points at which to map the finite-grid variance. |
source |
Whether to use observed threshold counts or planned design allocation probabilities. |
as_matrix |
Whether to return a covariance matrix. Cells in the same active PAVA pool have a shared nonzero covariance. |
A named numeric vector, or a covariance matrix when as_matrix = TRUE.
x <- stats::runif(200) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 3) fit <- ldp_estimate_cdf(reports) ldp_cdf_variance(fit, newdata = c(0.25, 0.75))x <- stats::runif(200) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 3) fit <- ldp_estimate_cdf(reports) ldp_cdf_variance(fit, newdata = c(0.25, 0.75))
Builds a self-normalized ellipsoidal confidence region from a many-quantile fit. The returned object contains the center, shape matrix, critical value, and helper functions for evaluating the statistic and checking membership.
ldp_confidence_region( object, level = 0.95, critical = NULL, n_sim = 5000L, n_grid = 400L, seed = 1L )ldp_confidence_region( object, level = 0.95, critical = NULL, n_sim = 5000L, n_grid = 400L, seed = 1L )
object |
An |
level |
Confidence level. |
critical |
Optional numeric critical value. |
n_sim, n_grid, seed
|
Simulation controls when |
An object of class ldp_confidence_region.
set.seed(1) x <- stats::rnorm(300) fit <- ldp_estimate_quantiles(x, c(0.25, 0.5, 0.75), epsilon = 2, bounds = c(-4, 4), rng = "pseudo", seed = 2) region <- ldp_confidence_region(fit, level = 0.8, n_sim = 200, n_grid = 50) region$contains(coef(fit))set.seed(1) x <- stats::rnorm(300) fit <- ldp_estimate_quantiles(x, c(0.25, 0.5, 0.75), epsilon = 2, bounds = c(-4, 4), rng = "pseudo", seed = 2) region <- ldp_confidence_region(fit, level = 0.8, n_sim = 200, n_grid = 50) region$contains(coef(fit))
Returns finite-block critical values used by the divide-and-conquer CDF studentized interval. Values are interpolated on the log block-count scale from the 2026 D&C CDF supplementary implementation.
ldp_dc_critical(blocks, level = 0.95)ldp_dc_critical(blocks, level = 0.95)
blocks |
Number of divide-and-conquer blocks. |
level |
Confidence level. Currently tabulated finite-block values are available for 95 percent intervals. |
A numeric vector of critical values.
ldp_dc_critical(c(8, 32, 128))ldp_dc_critical(c(8, 32, 128))
Creates a design object describing the public queries used during local data collection. The design is separate from the privacy mechanism so that the same estimator can be paired with different randomizers or threshold schemes.
ldp_design( task = c("cdf", "quantile", "quantiles", "category_cdf"), grid = NULL, tau = NULL, bounds = NULL, categories = NULL, assignment = c("random", "cyclic"), weights = NULL, ... )ldp_design( task = c("cdf", "quantile", "quantiles", "category_cdf"), grid = NULL, tau = NULL, bounds = NULL, categories = NULL, assignment = c("random", "cyclic"), weights = NULL, ... )
task |
Statistical task. |
grid |
Threshold grid for CDF designs. The grid is stored in increasing order. |
tau |
Quantile levels for quantile designs. |
bounds |
Optional finite support or projection bounds. |
categories |
Optional category labels. Category-CDF labels may be character, factor-like, or numeric values; reports store their internal 0-based indices. |
assignment |
How thresholds are assigned to users. |
weights |
Optional threshold sampling probabilities. If |
... |
Reserved for task-specific options. |
An object of class ldp_design.
design <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) designdesign <- ldp_design("cdf", grid = seq(0, 1, length.out = 11)) design
Recovers category-specific sub-CDFs from asymmetrically censored randomized response reports. The default implementation uses componentwise marginal isotonic regression. The optional projected procedure uses Dykstra projection onto the shared feasible set and is not presented as an exact ICM likelihood maximizer.
ldp_estimate_category_cdf( reports, method = c("marginal", "projected", "global_icm"), cap_total = TRUE, max_iter = 100L, tol = 1e-07 ) ## S3 method for class 'ldp_category_cdf_fit' predict(object, newdata = NULL, ...)ldp_estimate_category_cdf( reports, method = c("marginal", "projected", "global_icm"), cap_total = TRUE, max_iter = 100L, tol = 1e-07 ) ## S3 method for class 'ldp_category_cdf_fit' predict(object, newdata = NULL, ...)
reports |
An |
method |
Estimation method. |
cap_total |
Whether to cap the total recovered CDF at one by freezing
sub-CDFs after the first crossing for |
max_iter |
Maximum number of projected iterations; must be a positive integer. |
tol |
Convergence tolerance for the projected updates. |
object |
A fitted category CDF object. |
newdata |
Points at which to evaluate the fitted sub-CDFs. |
... |
Unused. |
An object of class ldp_category_cdf_fit; predict() returns a data
frame containing the total CDF and one sub-CDF column per category. Prediction
is restricted to the fitted threshold range. Projected fits also store
convergence diagnostics in diagnostics.
set.seed(1) x <- stats::runif(100) y <- sample(c("A", "B"), 100, replace = TRUE) design <- ldp_design("category_cdf", grid = seq(0, 1, length.out = 11), categories = c("A", "B"), y = y) mech <- ldp_mechanism("uldp_censor", epsilon = 2, domain_size = 2) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 1) fit <- ldp_estimate_category_cdf(reports) predict(fit, c(0.25, 0.5)) projected <- ldp_estimate_category_cdf(reports, method = "projected")set.seed(1) x <- stats::runif(100) y <- sample(c("A", "B"), 100, replace = TRUE) design <- ldp_design("category_cdf", grid = seq(0, 1, length.out = 11), categories = c("A", "B"), y = y) mech <- ldp_mechanism("uldp_censor", epsilon = 2, domain_size = 2) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 1) fit <- ldp_estimate_category_cdf(reports) predict(fit, c(0.25, 0.5)) projected <- ldp_estimate_category_cdf(reports, method = "projected")
Fits the monotone current-status CDF estimator from binary randomized
response threshold reports. The implementation applies weighted isotonic
regression to the privatized threshold means, then maps the fitted curve back
to the original CDF scale and clips it to [0, 1].
The divide-and-conquer method fits the same estimator independently over
blocks and averages the fitted values.
vcov(), ldp_cdf_variance(), and confint() use finite-grid
covariance formulas that account for randomized-response inflation, active
PAVA pools, and public threshold allocation. The normal limits use the realized
active pools as fixed and do not adjust for active-set selection or simultaneous
coverage.
ldp_estimate_cdf(reports, grid = NULL, method = c("isotonic", "dc"), blocks = NULL) ## S3 method for class 'ldp_cdf_fit' confint( object, parm, level = 0.95, critical = c("normal", "dc_finite_block"), newdata = NULL, variance = c("observed", "planned"), ... ) ## S3 method for class 'ldp_cdf_fit' predict(object, newdata = NULL, ...) ## S3 method for class 'ldp_cdf_fit' summary(object, ...) ## S3 method for class 'ldp_cdf_fit' vcov(object, ...)ldp_estimate_cdf(reports, grid = NULL, method = c("isotonic", "dc"), blocks = NULL) ## S3 method for class 'ldp_cdf_fit' confint( object, parm, level = 0.95, critical = c("normal", "dc_finite_block"), newdata = NULL, variance = c("observed", "planned"), ... ) ## S3 method for class 'ldp_cdf_fit' predict(object, newdata = NULL, ...) ## S3 method for class 'ldp_cdf_fit' summary(object, ...) ## S3 method for class 'ldp_cdf_fit' vcov(object, ...)
reports |
An |
grid |
Optional prediction grid. |
method |
Estimator type. |
blocks |
Number of blocks for |
object |
An |
parm |
Unused. |
level |
Nominal confidence level for pointwise plug-in Wald limits. |
newdata |
Points at which to evaluate the fitted CDF or confidence interval. |
critical |
Critical value method for |
variance |
Variance source for finite-grid isotonic fits: observed threshold counts or planned design allocation. |
... |
Unused. |
An object of class ldp_cdf_fit; predict() returns a data frame.
set.seed(1) x <- stats::runif(200) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, length.out = 21)) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 2) fit <- ldp_estimate_cdf(reports) predict(fit, c(0.25, 0.5, 0.75))set.seed(1) x <- stats::runif(200) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, length.out = 21)) reports <- ldp_randomize(x, mech, design, rng = "pseudo", seed = 2) fit <- ldp_estimate_cdf(reports) predict(fit, c(0.25, 0.5, 0.75))
Runs the online binary-response quantile recursion and returns the
Polyak-Ruppert averaged estimate. The fit stores the self-normalizer needed
for inference without estimating the density at the target quantile.
The stored normalizer is not a covariance estimate, so vcov() returns
an informative error.
ldp_estimate_quantile( x, tau = 0.5, mechanism = ldp_mechanism("binary_rr", epsilon), epsilon, init = 0, step_scale = 1, step_power = 0.6, rng = c("secure", "pseudo"), seed = NULL, keep_path = FALSE ) ## S3 method for class 'ldp_quantile_fit' coef(object, ...) ## S3 method for class 'ldp_quantile_fit' vcov(object, ...) ## S3 method for class 'ldp_quantile_fit' confint( object, parm, level = 0.95, critical = "self_normalized", n_sim = 20000L, n_grid = 1000L, seed = 1L, ... ) ## S3 method for class 'ldp_quantile_fit' summary(object, ...)ldp_estimate_quantile( x, tau = 0.5, mechanism = ldp_mechanism("binary_rr", epsilon), epsilon, init = 0, step_scale = 1, step_power = 0.6, rng = c("secure", "pseudo"), seed = NULL, keep_path = FALSE ) ## S3 method for class 'ldp_quantile_fit' coef(object, ...) ## S3 method for class 'ldp_quantile_fit' vcov(object, ...) ## S3 method for class 'ldp_quantile_fit' confint( object, parm, level = 0.95, critical = "self_normalized", n_sim = 20000L, n_grid = 1000L, seed = 1L, ... ) ## S3 method for class 'ldp_quantile_fit' summary(object, ...)
x |
Numeric observations used to simulate sequential local randomization. |
tau |
Target quantile level. |
mechanism |
A binary randomized-response mechanism. |
epsilon |
Privacy budget used when |
init |
Initial query value. |
step_scale, step_power
|
Step-size parameters for
|
rng |
Randomness source. |
seed |
Optional pseudo-random seed for simulation. |
keep_path |
Whether to retain iterate and averaged paths. |
object |
An |
parm |
Unused. |
level |
Confidence level. |
critical |
The self-normalized method or a user-supplied numeric critical value. |
n_sim, n_grid
|
Simulation controls for the self-normalized critical value. |
... |
Unused. |
This function simulates the sequential protocol in one R process. It receives the observation vector and performs local randomization internally.
The self-normalized inference assumes independent observations and local
randomization, a unique target quantile with positive continuous density,
and the regularity and stability conditions of the online quantile procedure.
For a continuous CDF at the target, the quantile solves .
With discrete data the generalized quantile need not solve this equation;
computing a fit does not establish the applicability of the inferential limit.
An object of class ldp_quantile_fit.
set.seed(1) x <- stats::rnorm(500) fit <- ldp_estimate_quantile(x, tau = 0.5, epsilon = 2, init = 0, rng = "pseudo", seed = 10) coef(fit) confint(fit)set.seed(1) x <- stats::rnorm(500) fit <- ldp_estimate_quantile(x, tau = 0.5, epsilon = 2, init = 0, rng = "pseudo", seed = 10) coef(fit) confint(fit)
Runs a dynamic-chain parallel SGD procedure for one LDP quantile and combines the chain-wise variance estimator with a Gaussian confidence-sequence boundary.
ldp_estimate_quantile_cs( x, tau = 0.5, mechanism = ldp_mechanism("binary_rr", epsilon), epsilon, init = 0, initial_chains = 5L, growth = "log", log_base = 10, step_scale = 1, step_power = 0.6, alpha = 0.05, boundary = c("stitched", "mixture"), rho = 0.01, rng = c("secure", "pseudo"), seed = NULL, checkpoints = NULL ) ## S3 method for class 'ldp_quantile_cs' confint(object, parm, level = 1 - object$alpha, ...) ## S3 method for class 'ldp_quantile_cs' summary(object, ...)ldp_estimate_quantile_cs( x, tau = 0.5, mechanism = ldp_mechanism("binary_rr", epsilon), epsilon, init = 0, initial_chains = 5L, growth = "log", log_base = 10, step_scale = 1, step_power = 0.6, alpha = 0.05, boundary = c("stitched", "mixture"), rho = 0.01, rng = c("secure", "pseudo"), seed = NULL, checkpoints = NULL ) ## S3 method for class 'ldp_quantile_cs' confint(object, parm, level = 1 - object$alpha, ...) ## S3 method for class 'ldp_quantile_cs' summary(object, ...)
x |
Private numeric observations. |
tau |
Target quantile level. |
mechanism |
A binary randomized-response mechanism. |
epsilon |
Privacy budget used when |
init |
Initial value for each chain. |
initial_chains |
Initial number of parallel chains. |
growth |
The supported logarithmic chain-growth schedule. |
log_base |
Base for logarithmic chain growth; it must exceed
|
step_scale, step_power
|
Per-chain step-size controls, with exponent in
|
alpha |
Miscoverage level. |
boundary |
Gaussian confidence-sequence boundary. |
rho |
Mixture-boundary tuning parameter. |
rng |
Randomness source. |
seed |
Optional pseudo-random seed for simulation. |
checkpoints |
Optional integer times at which to store the sequence. |
object |
An |
parm, level, ...
|
Standard |
This function simulates the sequential protocol in one R process. It receives the observation vector and performs local randomization internally.
Inference assumes independent observations and local randomization, a unique target quantile with positive continuous density, a bounded density derivative, and the supported step-size and chain-growth schedules. The guarantee is asymptotic, not finite-sample time-uniform coverage.
For chain counts , iterate sums , and the overall averaged
estimate , the scale is the weighted variance of
, with weights .
Centering before scaling makes the result invariant to a common translation
of the data and initialization, including while a new chain catches up.
An object of class ldp_quantile_cs.
set.seed(1) x <- stats::rnorm(500) cs <- ldp_estimate_quantile_cs(x, tau = 0.5, epsilon = 2, rng = "pseudo", seed = 13) confint(cs)set.seed(1) x <- stats::rnorm(500) cs <- ldp_estimate_quantile_cs(x, tau = 0.5, epsilon = 2, rng = "pseudo", seed = 13) confint(cs)
Reduces the many-quantile problem to KRR interval-label estimation. At each
step the current quantile vector partitions the real line, the user's interval
label is privatized by KRR, and the server uses the unbiased one-hot decoder in
a projected Robbins-Monro update. The projection enforces noncrossing at every
iteration. This function is a simulation wrapper that receives the private
numeric vector and performs the local randomization internally.
Joint inference is provided by ldp_confidence_region(); confint()
returns an informative error rather than unsupported marginal intervals.
ldp_estimate_quantiles( x, tau, mechanism = ldp_mechanism("krr", epsilon, domain_size = length(tau) + 1L), epsilon, bounds, init = NULL, step_scale = NULL, step_power = 0.6, rng = c("secure", "pseudo"), seed = NULL, keep_path = FALSE ) ## S3 method for class 'ldp_quantiles_fit' coef(object, ...) ## S3 method for class 'ldp_quantiles_fit' confint(object, parm, level = 0.95, simultaneous = TRUE, ...) ## S3 method for class 'ldp_quantiles_fit' summary(object, ...)ldp_estimate_quantiles( x, tau, mechanism = ldp_mechanism("krr", epsilon, domain_size = length(tau) + 1L), epsilon, bounds, init = NULL, step_scale = NULL, step_power = 0.6, rng = c("secure", "pseudo"), seed = NULL, keep_path = FALSE ) ## S3 method for class 'ldp_quantiles_fit' coef(object, ...) ## S3 method for class 'ldp_quantiles_fit' confint(object, parm, level = 0.95, simultaneous = TRUE, ...) ## S3 method for class 'ldp_quantiles_fit' summary(object, ...)
x |
Private numeric observations. |
tau |
Strictly increasing vector of target quantile levels. |
mechanism |
KRR mechanism with domain size |
epsilon |
Privacy budget used when |
bounds |
Known projection bounds for the target quantiles. |
init |
Optional initial noncrossing quantile vector. |
step_scale, step_power
|
Step-size controls. When |
rng |
Randomness source. |
seed |
Optional pseudo-random seed for simulation. |
keep_path |
Whether to retain iterate and average paths. |
object |
An |
parm |
Unused. |
level |
Confidence level. |
simultaneous |
Unused compatibility argument. Marginal Gaussian intervals are not supplied by the multivariate self-normalization theory. |
... |
Unused. |
Joint self-normalized inference assumes independent observations and local randomization, unique target quantiles with positive continuous densities, and the regularity and stability conditions of the projected recursion. The true quantile vector must be strictly ordered and lie inside the supplied bounds. Numerical positive definiteness of the observed self-normalizer is also required to construct the region.
An object of class ldp_quantiles_fit.
set.seed(1) x <- stats::rnorm(300) mech <- ldp_mechanism("krr", epsilon = 2, domain_size = 4) fit <- ldp_estimate_quantiles(x, tau = c(0.25, 0.5, 0.75), mechanism = mech, bounds = c(-4, 4), rng = "pseudo", seed = 2) coef(fit)set.seed(1) x <- stats::rnorm(300) mech <- ldp_mechanism("krr", epsilon = 2, domain_size = 4) fit <- ldp_estimate_quantiles(x, tau = c(0.25, 0.5, 0.75), mechanism = mech, bounds = c(-4, 4), rng = "pseudo", seed = 2) coef(fit)
Computes Gaussian boundaries used by the asymptotic confidence-sequence construction.
ldp_gaussian_cs_boundary( time, alpha = 0.05, type = c("stitched", "mixture"), m = 1, rho = 0.01 )ldp_gaussian_cs_boundary( time, alpha = 0.05, type = c("stitched", "mixture"), m = 1, rho = 0.01 )
time |
Positive time index or vector of time indices. |
alpha |
Miscoverage level. |
type |
Boundary family. |
m |
Starting time for stitched boundaries. |
rho |
Mixture-boundary tuning parameter. |
A numeric vector of boundary widths on the unit-variance mean scale.
ldp_gaussian_cs_boundary(c(100, 1000), alpha = 0.05)ldp_gaussian_cs_boundary(c(100, 1000), alpha = 0.05)
Constructs an ldp_mechanism object with validated privacy and domain
parameters.
ldp_mechanism( type = c("binary_rr", "krr", "oue", "olh", "hadamard", "uldp_censor"), epsilon, domain_size = NULL, ... )ldp_mechanism( type = c("binary_rr", "krr", "oue", "olh", "hadamard", "uldp_censor"), epsilon, domain_size = NULL, ... )
type |
Mechanism family. |
epsilon |
Positive local privacy budget. |
domain_size |
Number of categories for categorical mechanisms. Hadamard response currently supports padded size up to 4096. |
... |
Reserved for mechanism-specific options. |
An object of class ldp_mechanism.
mech <- ldp_mechanism("binary_rr", epsilon = 1) mechmech <- ldp_mechanism("binary_rr", epsilon = 1) mech
Computes the median asymptotic variance lower bound for binary
randomized-response sequential LDP mechanisms,
1 / (4 * r^2 * n * f(m)^2), where r = tanh(epsilon / 2) and
f(m) is the density at the median. The diagnostic reports the privacy
variance inflation relative to the non-private median bound and, when an
estimator variance is supplied, the ratio of the lower bound to that variance.
ldp_median_efficiency( object = NULL, density_at_median, epsilon = NULL, n = NULL, estimator_variance = NULL )ldp_median_efficiency( object = NULL, density_at_median, epsilon = NULL, n = NULL, estimator_variance = NULL )
object |
Optional |
density_at_median |
Value of the population density at the median. |
epsilon |
Privacy budget. Required when |
n |
Sample size. Required when |
estimator_variance |
Optional variance to compare with the lower bound.
When omitted, the function returns the bounds and privacy inflation without
an efficiency ratio. Supplying |
An object of class ldp_median_efficiency.
ldp_median_efficiency(density_at_median = stats::dnorm(0), epsilon = 2, n = 1000) x <- stats::rnorm(500) fit <- ldp_estimate_quantile(x, tau = 0.5, epsilon = 2, rng = "pseudo", seed = 1) ldp_median_efficiency(fit, density_at_median = stats::dnorm(0))ldp_median_efficiency(density_at_median = stats::dnorm(0), epsilon = 2, n = 1000) x <- stats::rnorm(500) fit <- ldp_estimate_quantile(x, tau = 0.5, epsilon = 2, rng = "pseudo", seed = 1) ldp_median_efficiency(fit, density_at_median = stats::dnorm(0))
Approximates the critical value of the multivariate self-normalized Brownian statistic used by the many-quantile confidence region.
ldp_msn_critical(k, level = 0.95, n_sim = 5000L, n_grid = 400L, seed = 1L)ldp_msn_critical(k, level = 0.95, n_sim = 5000L, n_grid = 400L, seed = 1L)
k |
Dimension of the Brownian motion. |
level |
Quantile level. |
n_sim |
Number of simulated Brownian paths. |
n_grid |
Discretization grid size. |
seed |
Pseudo-random seed. A supplied integer seed is used locally and
the previous random state is restored afterwards. With |
A numeric critical value.
ldp_msn_critical(2, level = 0.8, n_sim = 200, n_grid = 50)ldp_msn_critical(2, level = 0.8, n_sim = 200, n_grid = 50)
Computes the weighted isotonic regression fit using the pool-adjacent-violators algorithm. This is an internal workhorse exposed because many LDP distributional estimators require monotone projections.
ldp_pava(y, weights = NULL, decreasing = FALSE, backend = c("auto", "C", "R"))ldp_pava(y, weights = NULL, decreasing = FALSE, backend = c("auto", "C", "R"))
y |
Numeric vector to be projected onto the monotone cone. |
weights |
Optional nonnegative weights. |
decreasing |
Whether to fit a decreasing sequence. |
backend |
Computation backend. |
A numeric vector of fitted monotone values.
ldp_pava(c(0.1, 0.4, 0.3, 0.8)) ldp_pava(c(0.1, 0.4, 0.3, 0.8), backend = "R")ldp_pava(c(0.1, 0.4, 0.3, 0.8)) ldp_pava(c(0.1, 0.4, 0.3, 0.8), backend = "R")
Reports the analytic likelihood-ratio bound associated with a mechanism. For
ordinary LDP mechanisms this checks the symmetric epsilon-LDP bound. For
the censored ULDP mechanism, the report explicitly states that the guarantee is
asymmetric and applies to the protected censored output rather than to all
original-value pairs.
ldp_privacy_check(mechanism)ldp_privacy_check(mechanism)
mechanism |
An |
An object of class ldp_privacy_check.
ldp_privacy_check(ldp_mechanism("binary_rr", epsilon = 1)) ldp_privacy_check(ldp_mechanism("uldp_censor", epsilon = 1, domain_size = 2))ldp_privacy_check(ldp_mechanism("binary_rr", epsilon = 1)) ldp_privacy_check(ldp_mechanism("uldp_censor", epsilon = 1, domain_size = 2))
Applies a local randomizer to private data. The current implementation supports threshold CDF reports with binary randomized response and censored category-CDF reports with the ULDP censoring mechanism.
ldp_randomize( x, mechanism, design, rng = c("secure", "pseudo"), seed = NULL, threshold = NULL )ldp_randomize( x, mechanism, design, rng = c("secure", "pseudo"), seed = NULL, threshold = NULL )
x |
Private user observations. |
mechanism |
An |
design |
An |
rng |
Randomness source. |
seed |
Optional pseudo-random seed for simulations. |
threshold |
Optional preassigned threshold vector for CDF designs. |
An object of class ldp_reports.
x <- c(0.2, 0.6, 0.9) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, by = 0.25), assignment = "cyclic") ldp_randomize(x, mech, design, rng = "pseudo", seed = 1)x <- c(0.2, 0.6, 0.9) mech <- ldp_mechanism("binary_rr", epsilon = 2) design <- ldp_design("cdf", grid = seq(0, 1, by = 0.25), assignment = "cyclic") ldp_randomize(x, mech, design, rng = "pseudo", seed = 1)
Applies categorical LDP mechanisms and decodes the resulting reports into
unbiased one-hot estimates. Implemented mechanisms are direct randomized
response ("krr"), optimized unary encoding ("oue"), optimized
local hashing ("olh"), and Hadamard response ("hadamard").
ldp_randomize_category(category, mechanism, rng = c("secure", "pseudo"), seed = NULL) ldp_decode_category(reports, mechanism = reports$mechanism)ldp_randomize_category(category, mechanism, rng = c("secure", "pseudo"), seed = NULL) ldp_decode_category(reports, mechanism = reports$mechanism)
category |
Integer vector of 0-based category labels. |
mechanism |
Categorical mechanism created by |
rng |
Randomness source. |
seed |
Optional pseudo-random seed for simulation. |
reports |
Categorical privatized reports. |
ldp_randomize_category() returns an ldp_category_reports object.
ldp_decode_category() returns a numeric matrix with one row per report
and one column per category.
cat <- c(0, 1, 2, 1) mech <- ldp_mechanism("krr", epsilon = 2, domain_size = 3) reports <- ldp_randomize_category(cat, mech, rng = "pseudo", seed = 1) ldp_decode_category(reports)cat <- c(0, 1, 2, 1) mech <- ldp_mechanism("krr", epsilon = 2, domain_size = 3) reports <- ldp_randomize_category(cat, mech, rng = "pseudo", seed = 1) ldp_decode_category(reports)
Generates uniforms using either a cryptographically secure byte source or R's pseudo-random generator. Secure generation uses openssl when available and otherwise ‘/dev/urandom’ on Unix-like systems.
ldp_rng_uniform(n, rng = c("secure", "pseudo"), seed = NULL)ldp_rng_uniform(n, rng = c("secure", "pseudo"), seed = NULL)
n |
Nonnegative integer number of uniforms. |
rng |
Randomness source. Use |
seed |
Optional integer seed for |
A numeric vector in [0, 1).
ldp_rng_uniform(3, rng = "pseudo", seed = 1)ldp_rng_uniform(3, rng = "pseudo", seed = 1)
Approximates the quantile of the scalar self-normalized Brownian statistic used by the online quantile confidence interval.
ldp_sn_critical(level = 0.95, n_sim = 20000L, n_grid = 1000L, seed = 1L)ldp_sn_critical(level = 0.95, n_sim = 20000L, n_grid = 1000L, seed = 1L)
level |
Quantile level. |
n_sim |
Number of Monte Carlo Brownian paths. |
n_grid |
Discretization grid size for Brownian paths. |
seed |
Pseudo-random seed. A supplied integer seed is used locally and
the previous random state is restored afterwards. With |
A numeric critical value.
ldp_sn_critical(level = 0.8, n_sim = 200, n_grid = 50)ldp_sn_critical(level = 0.8, n_sim = 200, n_grid = 50)
Returns the mechanisms, task families, estimators, and public functions available in ldpdist.
ldp_supported_methods()ldp_supported_methods()
A named list of character vectors.
ldp_supported_methods()ldp_supported_methods()
Base graphics plotting methods for CDF fits, category CDF fits, and quantile confidence sequences.
## S3 method for class 'ldp_cdf_fit' plot(x, ..., conf.int = FALSE, level = 0.95, xlab = "x", ylab = "CDF", main = "LDP CDF estimate") ## S3 method for class 'ldp_category_cdf_fit' plot(x, ..., xlab = "x", ylab = "Sub-CDF", main = "LDP category CDF estimates") ## S3 method for class 'ldp_quantile_cs' plot(x, ..., xlab = "Time", ylab = "Quantile", main = "LDP quantile confidence sequence")## S3 method for class 'ldp_cdf_fit' plot(x, ..., conf.int = FALSE, level = 0.95, xlab = "x", ylab = "CDF", main = "LDP CDF estimate") ## S3 method for class 'ldp_category_cdf_fit' plot(x, ..., xlab = "x", ylab = "Sub-CDF", main = "LDP category CDF estimates") ## S3 method for class 'ldp_quantile_cs' plot(x, ..., xlab = "Time", ylab = "Quantile", main = "LDP quantile confidence sequence")
x |
A fitted object from ldpdist. |
... |
Additional graphics arguments. |
conf.int |
Whether to add confidence bands for CDF fits. |
level |
Confidence level. |
xlab, ylab, main
|
Base graphics labels. |
The input object, invisibly.