Learn R Programming

sdcTable (version 0.32.2)

createArgusInput: Create input files for tauArgus

Description

create required input-files and batch-file for tau-argus given an sdcProblem object

Usage

createArgusInput(
  obj,
  typ = "microdata",
  verbose = FALSE,
  path = getwd(),
  solver = "FREE",
  method,
  primSuppRules = NULL,
  responsevar = NULL,
  shadowvar = NULL,
  costvar = NULL,
  requestvar = NULL,
  holdingvar = NULL,
  ...
)

Value

the filepath to the batch-file

Arguments

obj

an object of class sdcProblem from sdcTable

typ

(character) either "microdata" or "tabular"

verbose

(logical) if TRUE, the contents of the batch-file are written to the prompt

path

path, into which (temporary) files will be written to (amongst them being the batch-files). Each file written to this folder belonging to the same problem contains a random id in its filename.

solver

which solver should be used. allowed choices are

  • "FREE"

  • "CPLEX"

  • "XPRESS"

In case "CPLEX" is used, it is also mandatory to specify argument licensefile which needs to be the absolute path the the cplex license file

method

secondary cell suppression algorithm, possible choices include:

  • "MOD": modular approach. If specified, the following arguments in ... can additionally be set:

    • MaxTimePerSubtable: number specifiying max. time (in minutes) spent for each subtable

    • SingleSingle: 0/1 (default=1)

    • SingleMultiple: 0/1 (default=1)

    • MinFreq: 0/1 (default=1)

  • "GH": hypercube. If specified, the following arguments in ... can additionally be set:

    • BoundPercentage: Default percentage to proctect primary suppressed cells, default 75

    • ModelSize: are we dealing with a small (0) or large (1) model? (default=1)

    • ApplySingleton: should singletons be additionally protected? 0/1 (default=1)

  • "OPT": optimal cell suppression. If specified, the following arguments in ... can additionally be set:

    • MaxComputingTime: number specifiying max. allowed computing time (in minutes)

primSuppRules

rules for primary suppression, provided as a list. For details, please have a look at the examples below.

responsevar

which variable should be tabulated (defaults to frequencies). For details see tau-argus manual section 4.4.4.

shadowvar

if specified, this variable is used to apply the safety rules, defaults to responsevar. For details see tau-argus manual section 4.4.4.

costvar

if specified, this variable describes the costs of suppressing each individual cell. For details see tau-argus manual section 4.4.4.

requestvar

if specified, this variable (0/1-coded) contains information about records that request protection. Records with 1 will be protected in case a corresponding request rule matches. It is ignored, if tabular input is used.

holdingvar

if specified, this variable contains information about records that should be grouped together. It is ignored, if tabular input is used.

...

allows to specify additional parameters for selected suppression-method as described above as well as licensefile in clase "CPLEX" was specified in argument solver.

Examples

Run this code
# loading micro data from sdcTable
utils::data("microdata1", package="sdcTable")
microdata1$num1 <- rnorm(mean = 100, sd = 25, nrow(microdata1))
microdata1$num2 <- round(rnorm(mean = 500, sd=125, nrow(microdata1)),2)
microdata1$weight <- sample(10:100, nrow(microdata1), replace = TRUE)

dim_region <- hier_create(root = "Total", nodes = LETTERS[1:4])

dim_region_dupl <- hier_create(root = "Total", nodes = LETTERS[1:4])
dim_region_dupl <- hier_add(dim_region_dupl, root = "B", nodes = c("b1"))
dim_region_dupl <- hier_add(dim_region_dupl, root = "D", nodes = c("d1"))

dim_gender <- hier_create(root = "Total", nodes = c("male", "female"))

dimList <- list(region = dim_region, gender = dim_gender)
dimList_dupl  <- list(region = dim_region_dupl, gender = dim_gender)
dimVarInd <- 1:2
numVarInd <- 3:5
sampWeightInd <- 6

# creating an object of class \code{\link{sdcProblem-class}}
obj <- makeProblem(
  data = microdata1,
  dimList = dimList,
  dimVarInd = dimVarInd,
  numVarInd = numVarInd,
  sampWeightInd = sampWeightInd)

# creating an object of class \code{\link{sdcProblem-class}} containing "duplicated" codes
obj_dupl <- makeProblem(
  data = microdata1,
  dimList = dimList_dupl,
  dimVarInd = dimVarInd,
  numVarInd = numVarInd,
  sampWeightInd = sampWeightInd)

## create primary suppression rules
primSuppRules <- list()
primSuppRules[[1]] <- list(type = "freq", n = 5, rg = 20)
primSuppRules[[2]] <- list(type = "p", n = 5, p = 20)
# other supported formats are:
# list(type = "nk", n=5, k=20)
# list(type = "zero", rg = 5)
# list(type = "mis", val = 1)
# list(type = "wgt", val = 1)
# list(type = "man", val = 20)

## create batchInput object
bO_md1 <- createArgusInput(
  obj = obj,
  typ = "microdata",
  path = tempdir(),
  solver = "FREE",
  method = "OPT",
  primSuppRules = primSuppRules,
  responsevar = "num1")

bO_td1 <- createArgusInput(
  obj = obj,
  typ = "tabular",
  path = tempdir(),
  solver = "FREE",
  method = "OPT")

bO_td2 <- createArgusInput(
  obj = obj_dupl,
  typ = "tabular",
  path = tempdir(),
  solver = "FREE",
  method = "OPT")

if (FALSE) {
## in case CPLEX should be used, it is required to specify argument licensefile
bO_md2 <- createArgusInput(
  obj = obj,
  typ = "microdata1",
  path = tempdir(),
  solver = "CPLEX",
  method = "OPT",
  primSuppRules = primSuppRules,
  responsevar = "num1",
  licensefile = "/path/to/my/cplexlicense")
}

Run the code above in your browser using DataLab