add_constraint: Add new constraint to constraint table

Description Usage Arguments Value Examples

View source: R/sim_annealing.R

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

1
2
3
4
5
6
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## 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 July 2, 2020, 2:29 a.m.