Distribute number of swaps across lowest hierarchy level according to a predefined swaprate. The swaprate is applied such that a single swap counts as swapping 2 households. Number of swaps are randomly rounded up or down, if needed, such that the total number of swaps is in coherence with the swaprate.
NOTE: This is an internal function used for testing the C++-function distributeDraws which is used inside the C++-function recordSwap().
data: micro data containing the hierarchy levels and household ID
hierarchy: column indices of variables in data which refers to the geographic hierarchy in the micro data set. For instance county > municipality > district.
hid: column index in data which refers to the household identifier.
swaprate: double between 0 and 1 defining the proportion of households which should be swapped, see details for more explanations