balance_LP: Linear program that selects which controls to use in order to...

Description Usage Arguments Value

View source: R/balance_LP.R

Description

This linear program is used by optimize_controls() to choose which controls to select.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
balance_LP(
  z,
  X,
  importances,
  st,
  st_vals,
  S,
  q_s,
  N,
  solver,
  integer,
  time_limit,
  threads = 1,
  weight_comp = 1
)

Arguments

z

a factor with the ith entry equal to the treatment of unit i.

X

a matrix or data frame containing constraints in the columns. The number of rows should equal the length of z. Balance is achieved when a constraint sums to 0, such that numbers closer to 0 are better. When a constraint does not apply to a particular unit, the entry should be NA. This should typically be generated using generate_constraints().

importances

a vector with length equal to the number of constraints or columns in X. This can be generated using generate_constraints() and each nonnegative value denotes how much to prioritize each constraint, with the default being 1 for all constraints.

st

a stratum vector with the ith entry equal to the stratum of unit i. This should have the same order of units and length as z.

st_vals

the unique stratum levels contained in st.

S

the number of unique stratum levels contained in st.

q_s

a named vector or matrix indicating how many control units are to be selected from each stratum. If there is one control group and all treated units are desired, this can be a vector; otherwise, this should have one row per treatment group, where the order of the rows matches the order of the levels of z, including the treated level.

N

the total number of available controls in the data.

solver

a character stating which solver to use to run the linear program. Options are "Rglpk" (default) or "gurobi". You must have the 'gurobi' package installed to use the "gurobi" option. If available, this is the recommended solver.

integer

a logical stating whether to use a mixed integer programming solver instead of randomized rounding. Default is FALSE.

time_limit

numeric stating maximum amount of seconds for which the program is allowed to run before aborting. Default is Inf for no time limit.

threads

The maximum number of threads that should be used. This is only applicable if solver = 'gurobi'.

Value

A list containing two elements:

lpdetails

The output of either gurobi() or Rglpk_solve_LP(), except that if gurobi() is used, the elements objval and x are renamed optimum and solution to be consistent with the output of Rglpk_solve_LP().

o

The original output of either gurobi() or Rglpk_solve_LP().


natstrat documentation built on Oct. 15, 2021, 5:12 p.m.