adjustSex | R Documentation |
The APL Estimates Breakdown System (EBS) was unable to rake population estimates of CHSAs by Age and Sex, unless Sex was adjusted (aka, prorated) before it was raked (even more so than the prorating included within the raking function). (EBS first used CHSAs in 2019.)
adjustSex(InputData, CtrlPopTotals, years = NULL, VarSex = "Sex")
InputData |
Data variable containing the database to be adjusted. Expects data to be in data.frame with columns: Year, Type, TypeID, Sex, ages 0:100, TOTAL. If InputData's Age is wide, it will pivot the age columns long to column "Age". If any BC/overall counts are included (i.e., TypeID == 0), they are dropped. |
CtrlPopTotals |
Data variable containing the overall BC database to be adjusted against. Expects data to be in data.frame with columns: Year, Sex, ages 0:100, TOTAL. The Sex variable is assumed to be numeric, with the largest Sex value representing Total sex. |
years |
Vector of Years to adjust. Default = NULL. If NULL, the function will iterate over all years found in InputData (assuming such years are also in CtrlPopTotals). |
VarSex |
Name of Sex variable in both files (e.g., "Sex"). Note: Sex must be a numeric variable (e.g., 1,2,3) where the Total is the maximum number (e.g., 3. |
This function takes InputData and adjusts Sex by TypeID counts, compared to CtrlPopTotals (i.e., BC age sex population counts). InputData and CtrlPopTotals are assumed to already be in the environment. Historically, EBS had been run on the 89 LHAs (local health areas). EBS was first run on CHSAs in 2019 to break down the 218 CHSA estimate totals to age sex estimates. The results were erratic in that many young age children (0-5) were removed during the raking process rendering some CHSAs with very low or no children aged 0-5. This problem was fixed by first prorating the EBS output by sex (i.e., this adjustSex() function) using the BC level sex totals, then raking as usual.
Database with Sex adjusted to CtrlPopTotals, by TypeID.
dbConvert
Overall package documentation: dbutils
()
Other raking helpers:
add.random.fraction.to.cols()
,
allowNegsnoMargin()
,
calc.cols()
,
multiRake()
,
noNegsneedMargin()
,
noNegsnoMargin()
,
prep.prorate.col()
,
prorate.col()
,
prorate.row()
,
prorate()
,
read.inputs()
,
real.to.int()
,
rename.age.grps()
,
rounded()
## Not run: adjustSex(InputData = pop, CtrlPopTotals = BC_AGE_SEX, years = NULL, VarSex = "Sex") ## Not run: adjustSex(InputData = pop, CtrlPopTotals = BC_AGE_SEX)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.