noNegsneedMargin | R Documentation |
When raking, the appropriate algorithm is chosen (negative values allowed or not, margin needed
or not), "whole people" adjustments to be made to selected cells in a row are calculated, then
"residual people" adjustments to be made to selected cells in a row are calculated, then column
control totals are reconciled. Raking is run iteratively row-by-row. Regardless of the algorithm
needed, five arguments are needed. A sixth argument, "needMargin" is only needed for algorithm C
(noNegsneedMargin). This is a helper function used in dbRake
when negative values
are NOT allowed AND margin IS needed. Specifically, values need to be added to cells in current
row, and subtracted from lower rows. Because adjustments are subtracted from lower rows but
negative values are not allowed, a margin is needed.
noNegsneedMargin( CurrRow, CurrRow_value, data, n_colGrps, n_rowGrps, RowAdj, needMargin )
CurrRow |
a subset of data with 3 rows and columns: XXX, n_colGrps, Sum, Ctrl_TOTAL, Diff, adj_value, where XXX is Sex in Part 1, Region in Part 2, and Age in Part 3. The rows are the one XXX row currently being worked on, Adjustments, and AdjCurrRow. |
CurrRow_value |
a counter to iterate through rows in data |
data |
a dataframe of rows to be iteratively raked with columns: XXX, n_colGrps, Sum, Ctrl_TOTAL, Diff, adj_value, where XXX is the variable being raked (Sex in Part 1, Region in Part 2, Age in Part 3). Rows are the rows of XXX as well as three summary rows: Sum, Ctrl_TOTAL, Diff. |
n_colGrps |
the number of column groups to rake over (e.g., 89 LHAs, number of Age Groups, etc.) |
n_rowGrps |
the number of rows groups to rake over (e.g., 2 Sexes, 89 LHAs, etc.) |
RowAdj |
vector of zeros, of length n_colGrps (e.g., 89 zeros, etc.) |
needMargin |
a logical (TRUE or FALSE) of whether a margin is needed. The margin is the current row's Sum - CurrRow values - Adjustments - all rows above. |
original dataframe, but with CurrRow's Diff now 0, and any adjustments made to CurrRow reversed in the row below that has the largest minimum value
The overall raking function: dbRake
()
Other raking helpers:
add.random.fraction.to.cols()
,
adjustSex()
,
allowNegsnoMargin()
,
calc.cols()
,
multiRake()
,
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.