design: Generating design matrices

Description Usage Arguments Value Examples

View source: R/design.R

Description

This function generates the design matrix given an IV specification.

Usage

1
design(formula, data, subset, treat, orig.names)

Arguments

formula

Formula with which to generate the design matrix.

data

data.frame with which to generate the design matrix.

subset

Condition to select subset of data.

treat

The name of the treatment variable. This should only be passed when constructing OLS weights.

orig.names

character vector of the terms in the final design matrix. This is required when the user declares an IV-like formula where the treatment variable is passed into the factor function. Since the treatment variable has to be fixed to 0 or 1, the design matrix will be unable to construct the contrasts. The argument orig.names is a vector of the terms in the IV-like specification prior to fixing the treatment variable.

Value

Three matrices are returned: one for the outcome variable, Y; one for the second stage covariates, X; and one for the first stage covariates, Z.

Examples

1
2
3
4
dtm <- ivmte:::gendistMosquito()
design(formula = ey ~ d | z,
           data = dtm,
           subset = z %in% c(1, 2))

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