Skip to contents

Generates scaling multipliers that can be applied to contingency tables to align source distributions with reference prevalence estimates.

Usage

make_scaling_dt(
  agents_dt,
  scale_from_tb,
  scale_to_tb,
  age_coding_1L_chr = "four",
  age_new_1L_chr = "AgeGroup4",
  age_old_1L_chr = "agep",
  conditioned_on_chr = c("STE", "STEName", "AgeGroup4", "SEXP"),
  filters_ls = list(state = "5"),
  missing_1L_dbl = numeric(),
  new_missing_chr = c("Not stated", "_N"),
  new_options_chr = c("Yes", "No"),
  new_target_1L_chr = "MentalHealthCondition",
  new_total_chr = c("Total", "_T"),
  new_var_chr = c("Mental Health Condition", "91"),
  region_type_1L_chr = "STE",
  target_1L_chr = "lthp"
)

Arguments

agents_dt

Synthetic agent population.

scale_from_tb

Dataset supplying baseline prevalence estimates.

scale_to_tb

Dataset supplying target prevalence estimates.

age_coding_1L_chr

Age coding scheme.

age_new_1L_chr

Derived age-group variable.

age_old_1L_chr

Source age variable.

conditioned_on_chr

Variables used for conditioning.

filters_ls

Named list of filtering criteria.

missing_1L_dbl

Optional multiplier assigned to age groups for which no scaling factor can be calculated.

new_missing_chr

Labels for missing categories.

new_options_chr

Labels for binary categories.

new_target_1L_chr

Name of the target variable.

new_total_chr

Labels for total categories.

new_var_chr

Labels identifying positive cases.

region_type_1L_chr

Geographic level.

target_1L_chr

Source target variable.

Value

A data.table containing scaling multipliers.

Details

This function is commonly used when combining census-derived distributions with prevalence estimates obtained from survey data.

Examples

if (FALSE) { # \dontrun{
scaling_dt <- make_scaling_dt(
  agents_dt,
  scale_from_tb = census_tb,
  scale_to_tb = survey_tb
)
} # }