topBotCoding function

Top and Bottom Coding

Top and Bottom Coding

Function for Top and Bottom Coding. methods

topBotCoding(obj, value, replacement, kind = "top", column = NULL)

Arguments

  • obj: a numeric vector, a data.frame or a sdcMicroObj-class-object
  • value: limit, from where it should be top- or bottom-coded
  • replacement: replacement value.
  • kind: top or bottom
  • column: variable name in case the input is a data.frame or an object of class sdcMicroObj-class.

Returns

Top or bottom coded data or modified sdcMicroObj-class.

Details

Extreme values larger or lower than value are replaced by a different value (replacement in order to reduce the disclosure risk.

Note

top-/bottom coding of factors is no longer possible as of sdcMicro >=4.7.0

Examples

data(free1) res <- topBotCoding(free1[,"DEBTS"], value=9000, replacement=9100, kind="top") max(res) data(testdata) range(testdata$age) testdata <- topBotCoding(testdata, value=80, replacement=81, kind="top", column="age") range(testdata$age) ## for objects of class sdcMicro: data(testdata2) sdc <- createSdcObj(testdata2, keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'), numVars=c('expend','income','savings'), w='sampling_weight') sdc <- topBotCoding(sdc, value=500000, replacement=1000, column="income") testdataout <- extractManipData(sdc)

References

Templ, M. and Kowarik, A. and Meindl, B. Statistical Disclosure Control for Micro-Data Using the R Package sdcMicro. Journal of Statistical Software, 67 (4), 1--36, 2015. tools:::Rd_expr_doi("10.18637/jss.v067.i04")

See Also

indivRisk

Author(s)

Matthias Templ and Bernhard Meindl