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)

Arguments

...

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.

Value

a formula_branch object.

Details

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.

See also

Other formula branch functions: add_formula_branch()

Examples

# Define a formula branch.
model_specifications <- formula_branch(
  y ~ femininity,
  y ~ femininity + hurricane_strength,
  y ~ femininity * 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 ~ femininity,
  covariates = c("hurricane_strength", "Year", "Category", "NDAM")
)
model_specifications
#> <unnamed branch>  Options
#>     - (y ~ femininity)
#>   Covariates
#>     - hurricane_strength
#>     - Year
#>     - Category
#>     - NDAM