| calc.cols | R Documentation |
calculates necessary columns (Sum, Ctrl_TOTAL, Diff, adj_value) in preparation for prorating rows
or raking. First, it calculates the actual sum (of columns), then adds in VarRow control totals,
then calculates the difference, and finally calculates the adjustment value (difference divided by
number of groups). This is a helper function used in dbRake, and before calling prorate.row.
calc.cols(data, temp, VarRow, n_colGrps)
data |
a dataframe of initial population counts that need to be adjusted to control totals (e.g., columns: a region variable ("VarRow"), 1 (for Males), 2 (for Females)) |
temp |
a dataframe of control totals to adjust data to (e.g., region control totals) |
VarRow |
the name of the variable to join temp to data (e.g., VarRow for "LHA") |
n_colGrps |
the number of groups to adjust over (e.g., number of Sexes, 2); this is essentially the number of columns in data minus 1 (for the VarRow column) |
This function is first called in dbRake Part 1 to update initial initial estimates of male/female regional total values (before prorating rows, and again before raking), then again in Part 2 to update initial 5 year age group and maximum age group estimates by Sex (before prorating rows, and again before raking), and finally in Part 3 to update initial single year of age estimates by Sex (before prorating rows, and again before raking).
the original dataframe with four new columns (Sum, Ctrl_TOTAL, Diff, adj_value)
The overall raking function: dbRake()
Other raking helpers:
add.random.fraction.to.cols(),
adjustSex(),
allowNegsnoMargin(),
multiRake(),
noNegsneedMargin(),
noNegsnoMargin(),
prep.prorate.col(),
prorate.col(),
prorate.row(),
prorate(),
read.inputs(),
real.to.int(),
rename.age.grps(),
rounded()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.