add_constraint function

Add new constraint to constraint table

Add new constraint to constraint table

Add a new constraint to the mapping between a given macro dataset (class "macroACS") and a matching micro dataset (class "micro_synthetic). May be called repeatedly to create a set of constraints.

add_constraint( attr_name = "variable", attr_totals, micro_data, constraint_list = NULL )

Arguments

  • attr_name: The name of the attribute, or variable, that you wish to constrain.
  • attr_totals: A named integer vector of counts per level of the new constraining attribute.
  • micro_data: The micro dataset, of class "micro_synthetic", for which you wish to add a constraint.
  • constraint_list: A list of prior constraints on the same dataset which you wish to add to. Defaults to NULL (ie. the default is that this is the first constraint.)

Returns

A list of constraints.

Examples

## Not run: ## assumes that you have a micro_synthetic dataset named test_micro and attribute counts ## named a,e,g respectively c_list <- add_constraint(attr_name= "age", attr_totals= a, micro_data= test_micro) c_list <- add_constraint(attr_name= "edu_attain", attr_totals= e, micro_data= test_micro, constraint_list= c_list) c_list <- add_constraint(attr_name= "gender", attr_totals= g, micro_data= test_micro, constraint_list= c_list) ## End(Not run)
  • Maintainer: Alex Whitworth
  • License: MIT + file LICENSE
  • Last published: 2022-10-26

Useful links