Learn R Programming

mcmcsae (version 0.6.0)

computeDesignMatrix: Compute list of design matrices for all terms in a model formula

Description

The output is a list of dense or sparse design matrices for the specified model components with respect to data. The design matrices contain appropriate column names.

Usage

computeDesignMatrix(formula, data)

Arguments

formula

model formula.

data

data frame to be used in deriving the design matrices.

Value

A list of design matrices.

Examples

Run this code
# NOT RUN {
n <- 1000
dat <- data.frame(
  x = rnorm(n),
  f = factor(sample(1:50, n, replace=TRUE))
)
str(X <- computeDesignMatrix(~ x, dat)[[1]])
X <- computeDesignMatrix(
  ~ reg(~x, name="beta") + gen(~x, factor=~f, name="v"), dat
)
str(X)

# }

Run the code above in your browser using DataLab