An internal, convenience function that automatically transforms a vector, matrix, or data.frame with factors into a design matrix with indicator variables and an ommitted category. This is handy for using the SuperLearner and tmle packages

design_matrix(W)

Arguments

W

A vector, matrix, or data.frame that includes numeric or factor variables.

Value

A design matrix version of W where factor variables have been converted into columns of indicator variables with the first level excluded.

Details

The design_matrix function is used by agecurveAb and tmleAb as a data processing tool for functions that do not readily accommodate factor variables in a data.frame object. In particular, the SuperLearner() and tmle() functions typically have difficulty with factor variables and so this function transforms data before calling those functions.