knitr::opts_knit$set(
        stop_on_error = 2L
)
knitr::opts_chunk$set(
    fig.height = 7,
    fig.width = 7
)

Differentially Private Mean with dpMean

The dpMean class evaluates a privacy-preserving mean of a vector of values. The class supports any vector type that can be represented numerically, meaning that it can handle the R types numeric, integer, and logical.

Syntax

library(PSIlence)
x1 <- c(3, 12, 20, 42, 33, 65, 70, 54, 33, 45)
x2 <- c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE)
data <- data.frame(x1, x2)

dpMeanExample <- dpMean$new(mechanism='mechanismLaplace', varType='numeric', 
                      variable='x1', epsilon=0.1, n=10, rng=c(0, 70))
out <- dpMeanExample$release(data)
dpMeanExample2 <- dpMean$new(mechanism='mechanismLaplace', varType='logical', variable='x2', epsilon=0.1, n=10)
out2 <- dpMeanExample2$release(data)

Arguments

In typical usage, there are two methods to the dpGLM class. The new method, which creates an object of the class, accepts the following arguments.

 

The release method accepts a single argument.

Examples

Attach the sample dataset.

library(PSIlence)
data(PUMS5extract10000)

 

Calculate a private mean of a numeric vector with dpMean using the Laplace mechanism:

numericMean <- dpMean$new(mechanism='mechanismLaplace', varType='numeric', 
                           variable='income', n=10000, epsilon=0.1, rng=c(0, 750000))
numericMean$release(PUMS5extract10000)
print(numericMean$result)

 

To calculate the mean of a logical vector instead, input a logical vector into x and update varType and rng appropriately:

logicalMean <- dpMean$new(mechanism='mechanismLaplace', varType='logical', 
                           variable='married', n=10000, epsilon=0.1, rng=c(0, 1))
logicalMean$release(PUMS5extract10000)
print(logicalMean$result)

Values

The release method makes a call to the mechanism, which generates a list of statistical summaries available on the result field.

 

The list in the result attribute has the following values.



privacytoolsproject/PSI-Library documentation built on Feb. 17, 2020, 2:03 p.m.