Microaggregation for numerical and categorical key variables based on a distance similar to the Gower Distance
Microaggregation for numerical and categorical key variables based on a distance similar to the Gower Distance
The microaggregation is based on the distances computed similar to the Gower distance. The distance function makes distinction between the variable types factor,ordered,numerical and mixed (semi-continuous variables with a fixed probability mass at a constant value e.g. 0)
methods
variables: character vector with names of variables to be aggregated (Default for sdcMicroObj is all keyVariables and all numeric key variables)
aggr: aggregation level (default=3)
dist_var: character vector with variable names for distance computation
by: character vector with variable names to split the dataset before performing microaggregation (Default for sdcMicroObj is strataVar)
mixed: character vector with names of mixed variables
mixed.constant: numeric vector with length equal to mixed, where the mixed variables have the probability mass
trace: TRUE/FALSE for some console output
weights: numerical vector with length equal the number of variables for distance computation
numFun: function: to be used to aggregated numerical variables
catFun: function: to be used to aggregated categorical variables
addRandom: TRUE/FALSE if a random value should be added for the distance computation.
Returns
The function returns the updated sdcMicroObj or simply an altered data frame.
Details
The function sampleCat samples with probabilities corresponding to the occurrence of the level in the NNs. The function maxCat chooses the level with the most occurrences and random if the maximum is not unique.
Note
In each by group all distance are computed, therefore introducing more by-groups significantly decreases the computation time and memory consumption.