add_constraint: Add new constraint to constraint table

View source: R/sim_annealing.R

add_constraintR Documentation

Add new constraint to constraint table

Description

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.

Usage

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.)

Value

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)

synthACS documentation built on Oct. 26, 2022, 5:09 p.m.