Skip to contents

Creates a ReplicaAdder object for assigning attributes to a synthetic population using contingency tables.

Usage

ReplicaAdder(
  synth_pop,
  contingency,
  target_attribute,
  group_by = character(),
  missing_group_strategy = "borrow",
  warning_threshold = 0.05
)

Arguments

synth_pop

A synthetic population represented as a data.frame or data.table.

contingency

A contingency table describing the expected relationship between conditioning variables and the target attribute.

target_attribute

Character string identifying the attribute to be assigned.

group_by

Character vector specifying conditioning variables used during assignment.

missing_group_strategy

Character string specifying how groups missing from the contingency table should be handled. Options include "borrow", "overall" and "error".

warning_threshold

Numeric significance threshold used when generating validation warnings.

Value

A ReplicaAdder object.

Details

The resulting module can subsequently be configured using renew(), executed using enhance() and validated using ratify().

See also

ReplicaAdder, renew, enhance, ratify

Examples

age_gender <- data.frame(
  age_group = c("18-64", "65+"),
  count = c(10, 10)
)

population <- make_agents(
  age_gender
)

contingency <- data.frame(
  age_group = c("18-64", "65+"),
  education = c("Degree", "School"),
  count = c(60, 40)
)

adder <- ReplicaAdder(
  synth_pop = population,
  contingency = contingency,
  target_attribute = "education",
  group_by = "age_group"
)