genSSet: Generating moments/data for IV-like estimands

Description Usage Arguments Value Examples

View source: R/mst.R

Description

This function takes in the IV estimate and its IV-like specification, and generates a list containing the corresponding IV-like point estimate, and the corresponding moments (gammas) that will enter into the constraint matrix of the LP problem. If the option means = FALSE, then the data are not averaged to generate the gamma moments and may be used for GMM. The function requires the user to provide a list (i.e. the list the point estimates and moments corresponding to other IV-like specifications; or an empty list) to append these point estimates and moments to.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
genSSet(
  data,
  sset,
  sest,
  splinesobj,
  pmodobj,
  pm0,
  pm1,
  ncomponents,
  scount,
  subset_index,
  means = TRUE,
  yvar,
  dvar,
  noisy = TRUE,
  ivn = NULL,
  redundant = NULL
)

Arguments

data

data.frame used to estimate the treatment effects.

sset

list, which is modified and returned as the output. This object will contain all the information from the IV-like specifications that can be used for estimating the treatment effect.

sest

list containing the point estimates and S-weights corresponding to a particular IV-like estimand.

splinesobj

list of spline components in the MTRs for treated and control groups. Spline terms are extracted using removeSplines.

pmodobj

vector of propensity scores.

pm0

list of the monomials in the MTR for the control group.

pm1

list of the monomials in the MTR for the treated group.

ncomponents

The number of components from the IV regression to include in the S-set.

scount

integer, an index for the elements in the S-set.

subset_index

vector of integers, a row index for the subset of the data the IV regression is restricted to.

means

boolean, set to TRUE by default. If set to TRUE, then the gamma moments are returned, i.e. sample averages are taken. If set to FALSE, then no sample averages are taken, and a matrix is returned. The sample average of each column of the matrix corresponds to a particular gamma moment.

yvar

name of outcome variable. This is only used if means = FALSE, which occurs when the user believes the treatment effect is point identified.

dvar

name of treatment indicator. This is only used if means = FALSE, which occurs when the user believes the treatment effect is point identified.

noisy

boolean, default set to TRUE. If TRUE, then messages are provided throughout the estimation procedure. Set to FALSE to suppress all messages, e.g. when performing the bootstrap.

ivn

integer, the number indicating which IV specification the component corresponds to.

redundant

vector of integers indicating which components in the S-set are redundant.

Value

A list containing the point estimate for the IV regression, and the expectation of each monomial term in the MTR.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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(d),
                          treat = d,
                          list = FALSE)

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

ivmte documentation built on Sept. 17, 2021, 5:06 p.m.