redistributeCategory: Redistribute values from one or more categories among the...

Description Usage Arguments Details Value

Description

Take counts from one or more categories (eg an "Other" category") and allocate them the remaining categories, in proportion to the current size of those categories.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
redistributeCategory(
  counts,
  dimension,
  category,
  means = FALSE,
  epsilon = 0,
  n = NULL
)

## S4 method for signature 'Counts'
redistributeCategory(
  counts,
  dimension,
  category,
  means = FALSE,
  epsilon = 0,
  n = NULL
)

Arguments

counts

Object of class Counts consisting of non-negative integers, or a single non-negative integer.

dimension

Names or indices for dimensions whose categories are to be reallocated. If the dimensions have dimtypes "origin" and "destination" or "parent" and "child", then the base names may be used.

category

Names or indices of the categories to be reallocated.

means

If FALSE (the default) the allocation is done randomly; if TRUE, values are set equal to their means.

epsilon

Small quantity added to counts for remaining categories.

n

Number of iterations to generate. Ignored if counts or weights has a dimension with dimtype "iteration".

Details

When means is FALSE (the default) the allocation is done randomly, via multinomial draws. When means is FALSE the allocation is done deterministically, and exactly matches the existing distribution.

Argument epsilon provides a quick and dirty way of using the function with sparse data, when all of the remaining categories may be zero (so that the weights are undefined.) The quantity epsilon is added to all counts before calculating. With sparse data a better approach would be to fit a model and then redistribute using the fitted values, using function redistribute.

Value

A Counts object without the categories specified by categories.


StatisticsNZ/dembase documentation built on Dec. 25, 2021, 4:49 p.m.