View source: R/model-design-tools.R
enw_design | R Documentation |
This function is a wrapper around stats::model.matrix()
that
can optionally return a sparse design matrix defined as the unique
number of rows in the design matrix and an index vector that
allows the full design matrix to be reconstructed. This is useful
for models that have many repeated rows in the design matrix and that
are computationally expensive to fit. This function also allows
for the specification of contrasts for categorical variables.
enw_design(formula, data, no_contrasts = FALSE, sparse = TRUE, ...)
formula |
An R formula. |
data |
A |
no_contrasts |
A vector of variable names that should not be
converted to contrasts. If |
sparse |
Logical, if TRUE return a sparse design matrix. Defaults to TRUE. |
... |
Arguments passed on to
|
A list containing the formula, the design matrix, and the index.
Functions used to formulate models
enw_add_cumulative_membership()
,
enw_add_pooling_effect()
,
enw_effects_metadata()
,
enw_one_hot_encode_feature()
data <- data.frame(a = 1:3, b = as.character(1:3), c = c(1,1,2))
enw_design(a ~ b + c, data)
enw_design(a ~ b + c, data, no_contrasts = TRUE)
enw_design(a ~ b + c, data, no_contrasts = c("b"))
enw_design(a ~ c, data, sparse = TRUE)
enw_design(a ~ c, data, sparse = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.