sdcMicro (version 5.7.8)

topBotCoding: Top and Bottom Coding

Description

Function for Top and Bottom Coding.

Usage

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

Value

Top or bottom coded data or modified sdcMicroObj-class.

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.

Author

Matthias Templ and Bernhard Meindl

Details

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

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

Examples

Run this code
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)

Run the code above in your browser using DataCamp Workspace