design_matrix: Convert a vector, matrix or data frame with factors into a...

View source: R/design_matrix.R

design_matrixR Documentation

Convert a vector, matrix or data frame with factors into a design matrix

Description

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

Usage

design_matrix(W)

Arguments

W

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

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.

Value

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


ben-arnold/washb documentation built on Dec. 11, 2023, 7:06 p.m.