prep.prorate.col | R Documentation |
calculates necessary rows (Sum, Ctrl_TOTAL, Diff, adj_value) in preparation for prorating rows
or raking. First, it calculates the actual sum (of rows), 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.col
.
prep.prorate.col( data, n_rowGrps, colGrps, ctrl_total_row, AgeGrpMax = NULL, ageLast = NULL )
data |
a dataframe of inital population counts that need to be adjusted to control totals (e.g., columns: a region variable ("VarRow"), 1 (for Males), 2 (for Females)) |
n_rowGrps |
the number of groups to adjust over (e.g., number of groups in region) |
colGrps |
the number of groups to adjust over (e.g., number of Sexes, 2; number of Age Groups); this is essentially the number of columns in data minus 1 (for the VarRow column) or minus 2 (for the VarRow & Sex columns) |
ctrl_total_row |
a row of control totals to adjust data to (e.g., region control totals) |
AgeGrpMax |
age of the older population that will be prorated and raked separately from other 5 year age groups. AgeGrpMax will include all ages, including itself, through the remainder of the population. Default = NULL. If AgeGrpMax is not set, the function will use 75 and up (not necessarily the oldest age; that is, the oldest age is usually 100, meaning 100 and up). The BC Stats Demographics team determined that 75 was the best age for AgeGrpMax to ensure that distortion in older populations is minimized. When prep.prorate.col is called in Part 1 & 3, AgeGrpMax is NULL. AgeGrpMax is set to an age when prep.prorate.col is called in Part 2 when prorating older population, but is NULL when prorating remaining younger population. |
ageLast |
oldest age value. Default = NULL. When prep.prorate.col is called in Part 1 & 3, ageLast is NULL. ageLast is set when prep.prorate.col is called in Part 2 when prorating older population, but is NULL when prorating remaining younger population. |
This function is first called in dbRake Part 1 to update initial initial estimates of male/female regional total values (after prorating rows before prorating columns), then again in Part 2 to update initial 5 year age group and maximum age group estimates by Sex (after prorating rows before prorating columns) for the older population (vector called AgeGrpsOldest (e.g., "75-59" "80-84" "85-89" "90-94" "95-99" "100") determined by AgeGrpMax) and then again for (remaining) younger populations, and finally in Part 3 to update initial single year of age estimates by Sex (after prorating rows before prorating columns).
original dataframe, that is now prorated by the adjustment values
The overall raking function: dbRake
()
Other raking helpers:
add.random.fraction.to.cols()
,
adjustSex()
,
allowNegsnoMargin()
,
calc.cols()
,
multiRake()
,
noNegsneedMargin()
,
noNegsnoMargin()
,
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.