create_balance_matrices: Create matrix of balance constraints for linear program

Description Usage Arguments Value

View source: R/create_balance_matrices.R

Description

This creates the matrix of constraints that seek covariate balance for use in balance_LP() which creates the linear program used by optimize_controls() to choose which controls to select.

Usage

1
create_balance_matrices(X, z, N, nvars, kc2, q_s, return = "all")

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

z

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

N

the total number of available controls in the data.

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

return

one of "all", "A", or "X", denoting whether all matrices should be returned, or just A or just the X matrix blocks.

Value

A list containing up to three elements:

A

The matrix of covariate values and +/- 1s that are used as coefficients for the unit indicators and the epsilons in order to set the epsilons equal to the covariate imbalances.

x_blk

The covariate values used as coefficients for the unit indicators in the objective function.


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