GaussSuppression {SSBtools}  R Documentation 
Secondary suppression by Gaussian elimination
Description
Sequentially the secondary suppression candidates (columns in x) are used to reduce the xmatrix by Gaussian elimination. Candidates who completely eliminate one or more primary suppressed cells (columns in x) are omitted and made secondary suppressed. This ensures that the primary suppressed cells do not depend linearly on the nonsuppressed cells. How to order the input candidates is an important choice. The singleton problem and the related problem of zeros are also handled.
Usage
GaussSuppression(
x,
candidates = 1:ncol(x),
primary = NULL,
forced = NULL,
hidden = NULL,
singleton = rep(FALSE, nrow(x)),
singletonMethod = "anySum",
printInc = TRUE,
tolGauss = (.Machine$double.eps)^(1/2),
whenEmptySuppressed = warning,
whenEmptyUnsuppressed = message,
whenPrimaryForced = warning,
removeDuplicated = TRUE,
iFunction = GaussIterationFunction,
iWait = Inf,
xExtraPrimary = NULL,
unsafeAsNegative = FALSE,
...
)
Arguments
x 
Matrix that relates cells to be published or suppressed to inner cells. yPublish = crossprod(x,yInner) 
candidates 
Indices of candidates for secondary suppression 
primary 
Indices of primary suppressed cells 
forced 
Indices forced to be not suppressed. 
Indices to be removed from the above  
singleton 
Logical or integer vector of length 
singletonMethod 
Method for handling the problem of singletons and zeros:

printInc 
Printing "..." to console when TRUE 
tolGauss 
A tolerance parameter for sparse Gaussian elimination and linear dependency. This parameter is used only in cases where integer calculation cannot be used. 
whenEmptySuppressed 
Function to be called when empty input to primary suppressed cells is problematic. Supply NULL to do nothing. 
whenEmptyUnsuppressed 
Function to be called when empty input to candidate cells may be problematic. Supply NULL to do nothing. 
whenPrimaryForced 
Function to be called if any forced cells are primary suppressed (suppression will be ignored). Supply NULL to do nothing. The same function will also be called when there are forced cells marked as singletons (will be ignored). 
removeDuplicated 
Whether to remove duplicated columns in 
iFunction 
A function to be called during the iterations. See the default function, 
iWait 
The minimum number of seconds between each call to 
xExtraPrimary 
Extra xmatrix that defines extra primary suppressed cells in addition to those defined by other inputs. 
unsafeAsNegative 
When 
... 
Extra unused parameters 
Details
It is possible to specify too many (all) indices as candidates
.
Indices specified as primary
or hidded
will be removed.
Hidden indices (not candidates or primary) refer to cells that will not be published, but do not need protection.

Singleton methods for frequency tables: All singleton methods, except
"sub2Sum"
and theNumSingleton
methods, have been implemented with frequency tables in mind. The singleton method"subSum"
makes new imaginary primary suppressed cells, which are the sum of the singletons within each group. The"subSpace"
method is conservative and ignores the singleton dimensions when looking for linear dependency. The default method,"anySum"
, is between the other two. Instead of making imaginary cells of sums within groups, the aim is to handle all possible sums, also across groups. In addition,"subSumSpace"
and"subSumAny"
are possible methods, primarily for testing. These methods are similar to"subSpace"
and"anySum"
, and additional cells are created as in"subSum"
. It is believed that the extra cells are redundant. Note that in order to give information about unsafe cells,"anySum"
is internally changed to"subSumAny"
when there are forced cells. All the above methods assume that any published singletons are primary suppressed. If this is not the case, either"anySumNOTprimary"
or"anySum0"
must be used. Notably,"anySum0"
is an enhancement of"anySumNOTprimary"
for situations where zeros are singletons. Using that method avoids suppressing a zero marginal along with only one of its children. 
Singleton methods for magnitude tables: The singleton method
"sub2Sum"
makes new imaginary primary suppressed cells, which are the sum of two inner cells. This is done when a group contains exactly two primary suppressed inner cells provided that at least one of them is singleton. This was the first method implemented. Other magnitude methods follow the coding according toNumSingleton
. The"sub2Sum"
method is equivalent to"numFFT"
. Also note that"num"
,"numFFF"
and"numFTF"
are equivalent to"none"
. 
Combined: For advanced use,
singleton
can be a twoelement list with names"freq"
and"num"
. ThensingletonMethod
must be a corresponding named twoelement vector. For example:singletonMethod = c(freq = "anySumNOTprimary", num = "sub2Sum")
Value
Secondary suppression indices
Examples
# Input data
df < data.frame(values = c(1, 1, 1, 5, 5, 9, 9, 9, 9, 9, 0, 0, 0, 7, 7),
var1 = rep(1:3, each = 5),
var2 = c("A", "B", "C", "D", "E"), stringsAsFactors = FALSE)
# Make output data frame and x
fs < FormulaSums(df, values ~ var1 * var2, crossTable = TRUE, makeModelMatrix = TRUE)
x < fs$modelMatrix
datF < data.frame(fs$crossTable, values = as.vector(fs$allSums))
# Add primary suppression
datF$primary < datF$values
datF$primary[datF$values < 5 & datF$values > 0] < NA
datF$suppressedA < datF$primary
datF$suppressedB < datF$primary
datF$suppressedC < datF$primary
# zero secondary suppressed
datF$suppressedA[GaussSuppression(x, primary = is.na(datF$primary))] < NA
# zero not secondary suppressed by first in ordering
datF$suppressedB[GaussSuppression(x, c(which(datF$values == 0), which(datF$values > 0)),
primary = is.na(datF$primary))] < NA
# with singleton
datF$suppressedC[GaussSuppression(x, c(which(datF$values == 0), which(datF$values > 0)),
primary = is.na(datF$primary), singleton = df$values == 1)] < NA
datF