bartModelMatrix function

Create a matrix out of a vector or data.frame

Create a matrix out of a vector or data.frame

The external BART functions operate on matrices in memory. Therefore, if the user submits a vector or data.frame, then this function converts it to a matrix. Also, it determines the number of cutpoints necessary for each column when asked to do so.

bartModelMatrix(X, numcut=0L, usequants=FALSE, type=7, rm.const=FALSE, cont=FALSE, xinfo=NULL)

Arguments

  • X: A vector or data.frame to create the matrix from.

  • numcut: The maximum number of cutpoints to consider. If numcut=0, then just return a matrix; otherwise, return a list containing a matrix X, a vector numcut

    and a list xinfo.

  • usequants: If usequants is FALSE, then the cutpoints in xinfo are generated uniformly; otherwise, if TRUE, then quantiles are used for the cutpoints.

  • type: Determines which quantile algorithm is employed.

  • rm.const: Whether or not to remove constant variables.

  • cont: Whether or not to assume all variables are continuous.

  • xinfo: You can provide the cutpoints to BART or let BART choose them for you. To provide them, use the xinfo

    argument to specify a list (matrix) where the items (rows) are the covariates and the contents of the items (columns) are the cutpoints.

See Also

class.ind

Examples

set.seed(99) a <- rbinom(10, 4, 0.4) table(a) x <- runif(10) df <- data.frame(a=factor(a), x=x) b <- bartModelMatrix(df) b b <- bartModelMatrix(df, numcut=9) b b <- bartModelMatrix(df, numcut=9, usequants=TRUE) b ## Not run: f <- bartModelMatrix(as.character(a)) ## End(Not run)
  • Maintainer: Rodney Sparapani
  • License: GPL (>= 2)
  • Last published: 2024-06-21

Useful links