new_privacy: 'privacy' Object Constructor.

View source: R/privacy_class.R

new_privacyR Documentation

privacy Object Constructor.

Description

Creates a privacy object to be used as input into dapper_sample().

Usage

new_privacy(
  posterior_f = NULL,
  latent_f = NULL,
  mechanism_f = NULL,
  statistic_f = NULL,
  npar = NULL,
  varnames = NULL
)

Arguments

posterior_f

a function that draws posterior samples given the confidential data.

latent_f

A function with signature latent_f(theta) that generates a latent confidential dataset conditional on theta.

mechanism_f

a function that represents the log likelihood of the privacy mechanism.

statistic_f

a function that calculates the statistic to be released.

npar

dimension of the parameter being estimated.

varnames

an optional character vector of parameter names. Used to label summary outputs.

Details

  • posterior_f() is a function which makes draws from the posterior sampler. It has the syntax posterior_f(dmat, theta). Here dmat is a numeric matrix representing the confidential database and theta is a numeric vector which serves as the initialization point for a one sample draw. The easiest, bug-free way to construct posterior_f() is to use a conjugate prior. However, this function can also be constructed by wrapping a MCMC sampler generated from other R packages (e.g. rstan, fmcmc, adaptMCMC).

  • latent_f(theta) must take exactly one argument named theta, a numeric vector of length npar. It must return a matrix with one confidential record per row and one data variable per column. The records (rows) must be independent and identically distributed conditional on theta. Variables within a record may be dependent. The returned matrix must have the same dimensions on every call. For univariate data, return a one-column matrix.

  • mechanism_f() is a function that represents the log of the privacy mechanism density. This function has the form mechanism_f(sdp, sx) where sdp and sx are both either a numeric vector or matrix. The arguments must appear in the exact stated order with the same variables names as mentioned. Finally, the return value of mechanism_f() must be a numeric vector of length one.

  • statistic_f(xi, sdp, i) computes one record's contribution to the statistic used by the privacy mechanism. xi is row i of the latent confidential dataset, supplied as a vector. sdp is the observed privatized release, and i is the row index. Argument names and order must match this signature.

    The sampler sums these contributions over all records and passes the result as sx to mechanism_f(sdp, sx). Return a numeric vector when sdp is a numeric vector, or a matrix when sdp is a matrix. Contributions must have consistent lengths or dimensions across records.

  • npar is an integer equal to the dimension of theta.

Value

A S3 object of class privacy.


dapper documentation built on Sept. 6, 2026, 5:07 p.m.