if (FALSE) {
utils::data("microdata1", package = "sdcTable")
head(microdata1)
# define the problem
dim_region <- hier_create(root = "total", nodes = sort(unique(microdata1$region)))
dim_gender <- hier_create(root = "total", nodes = sort(unique(microdata1$gender)))
prob <- makeProblem(
data = microdata1,
dimList = list(region = dim_region, gender = dim_gender),
freqVarInd = NULL
)
# suppress some cells
prob <- primarySuppression(prob, type = "freq", maxN = 15)
# compute input for RegSDC-package
inp_regsdc <- createRegSDCInput(x = prob, chk = TRUE)
# estimate innner cells based on linear dependencies
res_regsdc <- RegSDC::SuppressDec(
x = as.matrix(inp_regsdc$x),
z = inp_regsdc$z_supp,
y = inp_regsdc$y)[, 1]
# check if inner cells are all protected
df <- data.frame(
freqs_orig = inp_regsdc$z[inp_regsdc$info$is_innercell == TRUE, ],
freqs_supp = inp_regsdc$z_supp[inp_regsdc$info$is_innercell == TRUE, ],
regsdc = res_regsdc
)
subset(df, df$regsdc == df$freqs_orig & is.na(freqs_supp))
}
Run the code above in your browser using DataLab