Learn R Programming

ivmte (version 1.1.0)

lpSetup: Constructing LP problem

Description

This function takes in the IV estimates from the set of IV regressions declared by the user, as well as their corresponding moments of the terms in the MTR. These are then used to construct the components that make up the LP problem. Additional constraint matrix is added using mbA (mb stands for "monotonicity/boundedness"); extra model sense is added using mbs; extra RHS values added using mbrhs). Depending on the linear programming solver used, this function will return different output specific to the solver.

Usage

lpSetup(sset, orig.sset = NULL, mbA = NULL, mbs = NULL,
  mbrhs = NULL, lpsolver, shape = TRUE)

Arguments

sset

List of IV-like estimates and the corresponding gamma terms.

orig.sset

list, only used for bootstraps. The list caontains the gamma moments for each element in the S-set, as well as the IV-like coefficients.

mbA

Matrix used to define the constraints in the LP problem.

mbs

Vector of model sense/inequalities signs used to define the constraints in the LP problem.

mbrhs

Vector of constants used to define the constraints in the LP problem.

lpsolver

string, name of the package used to solve the LP problem.

shape

boolean, default set to TRUE. Switch to determine whether or not to include shape restrictions in the LP problem.

Value

A list of matrices and vectors necessary to define an LP problem for Gurobi.

Examples

Run this code
# NOT RUN {
dtm <- ivmte:::gendistMosquito()

## Declare empty list to be updated (in the event multiple IV like
## specifications are provided
sSet <- list()

## Declare MTR formulas
formula1 = ~ 1 + u
formula0 = ~ 1 + u

## Construct object that separates out non-spline components of MTR
## formulas from the spline components. The MTR functions are
## obtained from this object by the function 'genSSet'.
splinesList = list(removeSplines(formula0), removeSplines(formula1))

## Construct MTR polynomials
polynomials0 <- polyparse(formula = formula0,
                 data = dtm,
                 uname = u,
                 as.function = FALSE)
polynomials1 <- polyparse(formula = formula0,
                 data = dtm,
                 uname = u,
                 as.function = FALSE)

## Generate propensity score model
propensityObj <- propensity(formula = d ~ z,
                            data = dtm,
                            link = "linear")

## Generate target gamma moments
ivEstimates <- ivEstimate(formula = ey ~ d | z,
                          data = dtm,
                          components = l(intercept, d),
                          treat = d,
                          list = FALSE)

## Construct S-set, which contains the coefficients and weights
## corresponding to various IV-like estimands
sSet <- genSSet(data = dtm,
                sset = sSet,
                sest = ivEstimates,
                splinesobj = splinesList,
                pmodobj = propensityObj$phat,
                pm0 = polynomials0,
                pm1 = polynomials1,
                ncomponents = 2,
                scount = 1,
                yvar = "ey",
                dvar = "d",
                means = TRUE)

## Construct the LP problem to be solved using lpSolveAPI
lpSetup(sset = sSet$sset, lpsolver = "lpSolveAPI")

# }

Run the code above in your browser using DataLab