Learn R Programming

aglm (version 0.4.1)

getUDummyMatForOneVec: Create a U-dummy matrix for one variable

Description

Create a U-dummy matrix for one variable

Usage

getUDummyMatForOneVec(
  x_vec,
  levels = NULL,
  drop_last = TRUE,
  only_info = FALSE
)

Value

A list with the following fields:

  • levels: Same as input.

  • drop_last: Same as input.

  • dummy_mat: The created U-dummy matrix (only if only_info=FALSE).

Arguments

x_vec

A vector representing original variable. The class of x_vec should be one of integer, character, or factor.

levels

A character vector representing values of x_vec used to create U-dummies. If NULL, all the unique values of x_vec are used to create dummies.

drop_last

If TRUE, the last column of the resulting matrix is dropped to avoid multicollinearity.

only_info

If TRUE, only information fields of returned values are filled and no dummy matrix is returned.

Author

Kenji Kondo