mafast {sdcMicro} | R Documentation |
Fast and Simple Microaggregation
Description
Function to perform a fast and simple (primitive) method of microaggregation. (for large datasets)
Usage
mafast(obj, variables = NULL, by = NULL, aggr = 3, measure = mean)
Arguments
obj |
either a |
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) |
Value
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.
Author(s)
Alexander Kowarik
See Also
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"
)
})
[Package sdcMicro version 5.7.8 Index]