# 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)
## Perform audit procedure and return bounds
audit(data = dtm,
uname = u,
m0 = formula0,
m1 = formula1,
splinesobj = splinesList,
vars_data = colnames(dtm),
vars_mtr = "u",
terms_mtr0 = "u",
terms_mtr1 = "u",
sset = sSet$sset,
gstar0 = targetGamma$gstar0,
gstar1 = targetGamma$gstar1,
m0.inc = TRUE,
m1.dec = TRUE,
m0.lb = 0.2,
m1.ub = 0.8,
audit.max = 5,
lpsolver = "lpSolveAPI")
# }
Run the code above in your browser using DataLab