topBotCoding {sdcMicro} | R Documentation |
Top and Bottom Coding
Description
Function for Top and Bottom Coding.
Usage
topBotCoding(obj, value, replacement, kind = "top", column = NULL)
Arguments
obj |
a numeric vector, a |
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 |
Details
Extreme values larger or lower than value
are replaced by a different value (replacement
in order to reduce the disclosure risk.
Value
Top or bottom coded data or modified sdcMicroObj-class
.
Note
top-/bottom coding of factors is no longer possible as of sdcMicro >=4.7.0
Author(s)
Matthias Templ and Bernhard Meindl
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. doi:10.18637/jss.v067.i04
See Also
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)