This function generates the design matrix given an IV
specification.
Usage
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.