This function allows to define perturbation parameters used to perturb cells in magnitude tables.

ck_params_nums(
  type = "top_contr",
  top_k = NULL,
  ptab,
  mult_params,
  mu_c = 0,
  same_key = TRUE,
  use_zero_rkeys = FALSE,
  path = NULL
)

Arguments

type

a character value defining the way to identify the magnifier, e.g which contributions/values in a cell should be the used in the perturbation procedure. Possible choices are:

  • top_contr: the k largest contributions are used. In this case, it is also required to specify argument top_k

  • mean: the (weighted) cellmean is used as starting point

  • range: the difference between largest and smallest contribution is used.

  • sum: the (weighted) cellvalue itself is used as starting point

top_k

it is ignored if variant is different from top_contr. Otherwise, a scalar number >0 is expected.

ptab

in this argument, one ore more perturbation tables are given as input. the following choices are possible:

  • an object derived from ptable::create_ptable() or ptable::create_num_ptable(): this case is the same as specifying a named list with only a single element "all" (as described below)

  • a named list where the allowed names are shown below and each element must be the output of [ptable::create_ptable())] or ptable::create_num_ptable()

    • "all": this ptable will be used for all cells; if specified, no elements named "even" or "odd" must exist.

    • "even": will be used to look up perturbation values for cells with an even number of contributors. if specified, also list-element "odd" must exist.

    • "odd": will be used to look up perturbation values for cells with an odd number of contributors; if specified, also list-element "even" must exist.

    • "small_cells": if specified, this ptable will be used to extract perturbation values for very small cells

[ptable::create_ptable())]: R:ptable::create_ptable()) ptable::create_num_ptable(): R:ptable::create_num_ptable()

mult_params

an object derived with ck_flexparams() or ck_simpleparams() that contain required parameters for the computation of the perturbation multiplier

mu_c

fixed extra protection amount (>= 0) applied to the absolute of the perturbation value of the first (largest) noise component if the cell is sensitive. This value defaults to 0 (no additional protection). Please note that sensitive cells can be defined according using the supp_freq(), supp_val, supp_p(), supp_nk() and supp_pq() methods. An examples is given in ?cellkey_pkg.

same_key

(logical) should original cell key (TRUE) used for for finding perturbation values of the largest contributor to a cell or should a perturbation of the cellkey itself (FALSE) take place.

use_zero_rkeys

(logical) scalar defining if record keys of units not contributing to a specific numeric variables should be used (TRUE) or ignored (FALSE) when computing cell keys.

path

a scalar character specifying a path to which the parameters created with this functions should be written to (in yaml format)

Value

an object suitable as input to method $params_nums_set() for the perturbation of continous variables.

See also

Examples

# create a perturbation table using
# functionality from ptable-pkg; see help(pa = "ptable")
# this returns an extra ptable for very small cells
ptab <- ptable::pt_ex_nums(separation = TRUE)

# create parameters
ck_params_nums(
  type = "top_contr",
  top_k = 3,
  ptab = ptab,
  mult_params = ck_flexparams(
    fp = 1000,
    p = c(0.20, 0.03),
    epsilon = c(1, 0.5, 0.2),
    q = 2),
  use_zero_rkeys = TRUE,
  mu_c = 3)
#> $params
#> $params$type
#> [1] "top_contr"
#> 
#> $params$top_k
#> [1] 3
#> 
#> $params$ptab
#>      i    j          p    v        lb        ub        type
#>   1: 0  0.0 1.00000000  0.0 0.0000000 1.0000000         all
#>   2: 1  0.0 0.27968425 -1.0 0.0000000 0.2796843         all
#>   3: 1  0.5 0.27968426 -0.5 0.2796843 0.5593685         all
#>   4: 1  1.0 0.27968425  0.0 0.5593685 0.8390528         all
#>   5: 1  1.5 0.05858542  0.5 0.8390528 0.8976382         all
#>  ---                                                       
#> 216: 5  9.2 0.00001179  4.2 0.9999801 0.9999919 small_cells
#> 217: 5  9.4 0.00000499  4.4 0.9999919 0.9999969 small_cells
#> 218: 5  9.6 0.00000203  4.6 0.9999969 0.9999989 small_cells
#> 219: 5  9.8 0.00000079  4.8 0.9999989 0.9999997 small_cells
#> 220: 5 10.0 0.00000030  5.0 0.9999997 1.0000000 small_cells
#> 
#> $params$mu_c
#> [1] 3
#> 
#> $params$m_fixed_sq
#> [1] 1
#> 
#> $params$zs
#> [1] 4.402255
#> 
#> $params$E
#> [1] 1.29
#> 
#> $params$mult_params
#> $fp
#> [1] 1000
#> 
#> $p_small
#> [1] 0.2
#> 
#> $p_large
#> [1] 0.03
#> 
#> $epsilon
#> [1] 1.0 0.5 0.2
#> 
#> $q
#> [1] 2
#> 
#> attr(,"class")
#> [1] "params_m_flex"
#> 
#> $params$same_key
#> [1] TRUE
#> 
#> $params$use_zero_rkeys
#> [1] TRUE
#> 
#> $params$even_odd
#> [1] FALSE
#> 
#> $params$separation
#> [1] TRUE
#> 
#> 
#> $type
#> [1] "params_m_flex"
#> 
#> attr(,"class")
#> [1] "ck_params"