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

View source: R/models.R

computeDesignMatrixR Documentation

Compute a list of design matrices for all terms in a model formula, or based on a sampler environment

Description

If sampler is provided instead of formula, the design matrices are based on the model used to create the sampler environment. In that case, if data is NULL, the design matrices stored in sampler are returned, otherwise the design matrices are computed for the provided data based on the sampler's model. The output is a list of dense or sparse design matrices for the model components with respect to data.

Usage

computeDesignMatrix(formula = NULL, data = NULL, labels = TRUE)

Arguments

formula

model formula.

data

data frame to be used in deriving the design matrices.

labels

if TRUE, column names are assigned.

Value

A list of design matrices.

Examples

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


mcmcsae documentation built on Oct. 11, 2023, 1:06 a.m.