verify_inputs: Verify the inputs to 'optimize_controls()'

Description Usage Arguments Value

View source: R/verify_optimize_controls_inputs.R

Description

Makes sure that the inputs to optimize_controls() are in the correct format and feasible.

Usage

1
verify_inputs(X, importances, ratio, q_s, st, z, treated, integer, solver)

Arguments

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.

ratio

a numeric or vector specifying the desired ratio of controls to 'treated' in each stratum. If there is one control group and all treated units should be included, this can be a numeric. Otherwise, this should be a vector with one entry per treatment group, in the same order as the levels of z, including the treated level. If NULL, q_s should be specified.

q_s

a named vector or matrix indicating how many 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. If NULL, ratio should be specified. If both are specified, q_s will take priority. Typically, if the desired ratio is not feasible for every stratum, q_s should be generated using generate_qs().

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.

z

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

treated

which treatment value should be considered the treated units. This must be one of the values of z.

integer

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

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.

Value

No return value. If there is a problem with the inputs to optimize_controls(), an error is raised.


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