polyparse: Parsing marginal treatment response formulas In ivmte: Instrumental Variables: Extrapolation by Marginal Treatment Effects

Description

This function takes in an MTR formula, and then parses the formula such that it becomes a polynomial in the unobservable `u`. It then breaks these polynomials into monomials, and then integrates each of them with respect to `u`. Each integral corresponds to E[md | D, X, Z].

Usage

 ```1 2 3 4 5 6 7``` ```polyparse( formula, data, uname = "u", env = parent.frame(), as.function = FALSE ) ```

Arguments

 `formula` the MTR. `data` `data.frame` for which we obtain E[md | D, X, Z] for each observation. `uname` variable name for unobservable used in declaring the MTR. `env` environment, the original environment in which the formula was declared. `as.function` boolean, if `FALSE` then a list of the polynomial terms are returned; if `TRUE` then a list of functions corresponding to the polynomials are returned.

Value

A list (of lists) of monomials corresponding to the original MTR (for each observation); a list (of lists) of the integrated monomials; a vector for the degree of each of the original monomials in the MTR; and a vector for the names of each variable entering into the MTR (note `x^2 + x` has only one term, `x`).

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```dtm <- ivmte:::gendistMosquito() ## Declare MTR functions formula1 = ~ 1 + u formula0 = ~ 1 + u ## 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) ```

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