SuppressDec: Suppressed tabular data: Inner cell frequencies as decimal...

View source: R/SuppressDec.R

SuppressDecR Documentation

Suppressed tabular data: Inner cell frequencies as decimal numbers

Description

Assume that frequencies to be published, z, can be computed from inner frequencies, y, via z = t(x) %*% y, where x is a dummy matrix. Assuming correct suppression, this function will generate safe inner cell frequencies as decimal numbers.

Usage

SuppressDec(
  x,
  z = NULL,
  y = NULL,
  suppressed = NULL,
  digits = 9,
  nRep = 1,
  yDeduct = NULL,
  resScale = NULL,
  rmse = NULL,
  sparseLimit = 500
)

Arguments

x

Dummy matrix where the dimensions matches z and/or y input. Sparse matrix (Matrix package) is possible.

z

Frequencies to be published. All, only the safe ones or with suppressed as NA.

y

Inner cell frequencies (see details).

suppressed

Logical vector defining the suppressed elements of z.

digits

Output close to whole numbers will be rounded using digits as input to RoundWhole.

nRep

Integer, when >1, several y's will be generated. Extra columns in output.

yDeduct

Values to be subtracted from y and added back after the calculations. Can be used to perform the modulo method described in the paper (see examples).

resScale

Residuals will be scaled by resScale

rmse

Desired root mean square error (residual standard error). Will be used when resScale is NULL or cannot be used.

sparseLimit

Limit for the number of rows of a reduced x-matrix within the algorithm. When exceeded, a sparse algorithm is used (see IpsoExtra).

Details

This function makes use of ReduceX and RegSDCipso. It is not required that y consists of cell frequencies. A multivariate y or z is also possible. Then several values are possible as digits, resScale and rmse input.

Value

The inner cell frequencies as decimal numbers

Note

Capital letters, X, Y and Z, are used in the paper.

Author(s)

Øyvind Langsrud

Examples

# Same data as in the paper
z <- RegSDCdata("sec7z")
x <- RegSDCdata("sec7x")
y <- RegSDCdata("sec7y")  # Now z is t(x) %*% y 
zAll <- RegSDCdata("sec7zAll")
zAllSupp <- RegSDCdata("sec7zAllSupp")
xAll <- RegSDCdata("sec7xAll")

# When no suppression, output is identical to y
SuppressDec(xAll, zAll, y)
SuppressDec(xAll, zAll)  # y can be seen in z

# Similar to Y* in paper (but other random values)
SuppressDec(x, z, y)

# Residual standard error forced to be 1
SuppressDec(x, z, y, rmse = 1)

# Seven ways of obtaining the same output
SuppressDec(x, z, rmse = 1)  # slower, y must be estimated
SuppressDec(x, y = y, rmse = 1)
SuppressDec(xAll, zAllSupp, y, rmse = 1)
SuppressDec(xAll, zAllSupp, rmse = 1)  # slower, y must be estimated
SuppressDec(xAll, zAll, y, is.na(zAllSupp), rmse = 1)
SuppressDec(xAll, zAll, suppressed = is.na(zAllSupp), rmse = 1)  # y seen in z
SuppressDec(xAll, y = y, suppressed = is.na(zAllSupp), rmse = 1)

# YhatMod4 and YhatMod10 in Table 2 in paper
SuppressDec(xAll, zAllSupp, y, yDeduct = 4 * (y%/%4), resScale = 0)
SuppressDec(xAll, zAllSupp, y, yDeduct = 10 * (y%/%10), rmse = 0)

# As data in Table 3 in paper (but other random values)
SuppressDec(xAll, zAllSupp, y, yDeduct = 10 * (y%/%10), resScale = 0.1)

# rmse instead of resScale and 5 draws
SuppressDec(xAll, zAllSupp, y, yDeduct = 10 * (y%/%10), rmse = 1, nRep = 5)

RegSDC documentation built on Aug. 19, 2022, 9:08 a.m.

Related to SuppressDec in RegSDC...