mafast function

Fast and Simple Microaggregation

Fast and Simple Microaggregation

Function to perform a fast and simple (primitive) method of microaggregation. (for large datasets) methods

mafast(obj, variables = NULL, by = NULL, aggr = 3, measure = mean)

Arguments

  • obj: either a sdcMicroObj-class-object or a data.frame
  • variables: variables to microaggregate. If obj is of class sdcMicroObj the numerical key variables are chosen per default.
  • by: grouping variable for microaggregation. If obj is of class sdcMicroObj the strata variables are chosen per default.
  • aggr: aggregation level (default=3)
  • measure: aggregation statistic, mean, median, trim, onestep (default = mean)

Returns

If obj was of class sdcMicroObj-class the corresponding slots are filled, like manipNumVars, risk and utility. If obj was of class data.frame or matrix an object of the same class is returned.

Examples

data(Tarragona) m1 <- mafast(Tarragona, variables=c("GROSS.PROFIT","OPERATING.PROFIT","SALES"),aggr=3) data(testdata) m2 <- mafast(testdata,variables=c("expend","income","savings"),aggr=50,by="sex") summary(m2) ## 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 <- dRisk(sdc) sdc@risk$numeric sdc1 <- mafast(sdc,aggr=4) sdc1@risk$numeric sdc2 <- mafast(sdc,aggr=10) sdc2@risk$numeric ### Performance tests x <- testdata for(i in 1:20){ x <- rbind(x,testdata) } system.time({ xx <- mafast( obj = x, variables = c("expend", "income", "savings"), aggr = 50, by = "sex" ) })

See Also

microaggregation

Author(s)

Alexander Kowarik