Learn R Programming

ivmte (version 1.1.0)

bound: Obtaining TE bounds

Description

This function estimates the bounds on the target treatment effect.

Usage

bound(g0, g1, sset, lpobj, obseq.factor, lpsolver, noisy = FALSE,
  debug = FALSE)

Arguments

g0

set of expectations for each terms of the MTR for the control group.

g1

set of expectations for each terms of the MTR for the control group.

sset

a list containing the point estimates and gamma components associated with each element in the S-set. This object is only used to determine the names of terms. If it is no submitted, then no names are provided to the solution vector.

lpobj

A list of matrices and vectors defining an LP problem.

obseq.factor

overall multiplicative factor for how much more the solution is permitted to violate observational equivalence of the IV-like estimands, i.e. obseq.factor will multiply minobseq directly.

lpsolver

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

noisy

boolean, set to TRUE if optimization results should be displayed.

debug

boolean, indicates whether or not the function should provide output when obtaining bounds. The option is only applied when lpsolver = 'gurobi'. The output provided is the same as what the Gurobi API would send to the console.

Value

a list containing the bounds on the treatment effect; the coefficients on each term in the MTR associated with the upper and lower bounds, for both counterfactuals; the optimization status to the maximization and minimization problems; the LP problem that the optimizer solved.

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 IV estimates
ivEstimates <- ivEstimate(formula = ey ~ d | z,
                          data = dtm,
                          components = l(intercept, d),
                          treat = d,
                          list = FALSE)

## Generate target gamma moments
targetGamma <- genTarget(treat = "d",
                         m0 = ~ 1 + u,
                         m1 = ~ 1 + u,
                         target = "atu",
                         data = dtm,
                         splinesobj = splinesList,
                         pmodobj = propensityObj,
                         pm0 = polynomials0,
                         pm1 = polynomials1,
                         point = 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)

## Define additional upper- and lower-bound constraints for the LP
## problem
A <- matrix(0, nrow = 22, ncol = 4)
A <- cbind(A, rbind(cbind(1, seq(0, 1, 0.1)),
                    matrix(0, nrow = 11, ncol = 2)))
A <- cbind(A, rbind(matrix(0, nrow = 11, ncol = 2),
                    cbind(1, seq(0, 1, 0.1))))

sense <- c(rep(">", 11), rep("<", 11))
rhs <- c(rep(0.2, 11), rep(0.8, 11))

## Construct LP object to be interpreted and solved by lpSolveAPI
lpObject <- lpSetup(sset = sSet$sset,
                    mbA = A,
                    mbs = sense,
                    mbrhs = rhs,
                    lpsolver = "lpSolveAPI")

## Estimate the bounds
bound(g0 = targetGamma$gstar0,
      g1 = targetGamma$gstar1,
      sset = sSet$sset,
      lpobj = lpObject,
      obseq.factor = 1,
      lpsolver = "lpSolveAPI")

# }

Run the code above in your browser using DataLab