sdcMicro (version 4.1.0)

freqCalc: Frequencies calculation for risk estimation

Description

Computation and estimation of the sample and population frequency counts.

Usage

freqCalc(x, keyVars, w = NULL, fast=TRUE)

Arguments

x
data frame or matrix
keyVars
key variables
w
column index of the weight variable. Should be set to NULL if one deal with a population.
fast
beta version of faster algorithm should not change the results in any way

Value

  • Object from class freqCalc.
  • freqCalcdata
  • keyVarskeyVars
  • windex of weight vector. NULL if you do not have a sample.
  • indexG
  • fkthe frequency of equal observations in the key variables subset sample given for each observation.
  • Fkestimated frequency in the population
  • n1amount of observations with fk=1
  • n2amount of observations with fk=2

Details

The function considers the case of missing values in the data. A missing value stands for any of the possible categories of the variable considered. It is possible to apply this function to large data sets with many (catergorical) key variables, since the computation is done in C. freqCalc() does not support sdcMicro S4 class objects.

References

look e.g. in http://neon.vb.cbs.nl/casc/Deliv/12d1.pdf Templ, M. Statistical Disclosure Control for Microdata Using the R-Package sdcMicro, Transactions on Data Privacy, vol. 1, number 2, pp. 67-85, 2008. http://www.tdp.cat/issues/abs.a004a08.php Templ, M. New Developments in Statistical Disclosure Control and Imputation: Robust Statistics Applied to Official Statistics, Suedwestdeutscher Verlag fuer Hochschulschriften, 2009, ISBN: 3838108280, 264 pages. Templ, M. and Meindl, B.: Practical Applications in Statistical Disclosure Control Using R, Privacy and Anonymity in Information Management Systems New Techniques for New Practical Problems, Springer, 31-62, 2010, ISBN: 978-1-84996-237-7.

See Also

indivRisk, measure_risk

Examples

Run this code
data(francdat)
f <- freqCalc(francdat, keyVars=c(2,4,5,6),w=8)
f
f$freqCalc
f$fk
f$Fk
## with missings:
x <- francdat
x[3,5] <- NA
x[4,2] <- x[4,4] <- NA
x[5,6]  <- NA
x[6,2]  <- NA
f2 <- freqCalc(x,  keyVars=c(2,4,5,6),w=8)
f2$Fk
# time comparison freqCalc old version  vs. new version
data(testdata)
system.time( f3 <-  freqCalc(testdata,keyVars=c(1:4,7),w=14,fast=FALSE) )
system.time( f3f <- freqCalc(testdata,keyVars=c(1:4,7),w=14,fast=TRUE) )

Run the code above in your browser using DataLab