View source: R/formula_branch.R
formula_branch | R Documentation |
The function specifies the model formula for fitting 'lm_mverse()' and
'glm_mverse()'. You can list the model specification formulae individually
or use covariates
option paired with one or more formulae.
formula_branch(..., covariates = NULL, name = NULL)
... |
branch definition expressions. |
covariates |
(optional) A character vector of optional covariates. Each unique combination of the supplied covariates is translated into a unique branch option. See Details. |
name |
(optional) Name for the new formula. |
The optional argument covariates
is allows you to specify a set of
optional covariates in addition to other independent variable such as
treatment variables and blocking variables which are specified using formula.
For each covariate provided, a branch is added to the multiverse with the
option to include or exclude the covariate in the model.
For example, formula_branch(y ~ x, covariates = c("c1", "c2"))
creates
the following 4 model specifications:
y ~ x
y ~ x + c1
y ~ x + c2
y ~ x + c1 + c2
Here, y
is the outcome variable and x
may be a treatment
variable in an experiment setting. c1
and c2
may be additional
covariates about the experiment units that may or may not be relevant.
a formula_branch
object.
Other formula branch functions:
add_formula_branch()
# Define a formula branch.
model_specifications <- formula_branch(
y ~ MasFem,
y ~ MasFem + hurricane_strength,
y ~ MasFem * hurricane_strength
)
# Create a mverse, add the branch.
mv <- create_multiverse(hurricane) %>%
add_formula_branch(model_specifications)
# Specify the covariates separately.
model_specifications <- formula_branch(
y ~ MasFem,
covariates = c("hurricane_strength", "Year", "Category", "NDAM")
)
model_specifications
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.