spells: Spells

spellsR Documentation

Spells

Description

[Stable]

This function defines a magical (modified) formula class that has been vectorized. The spell serves as a set of instructions or a script for the formula and its runes. It expands upon the functionality of formulas, allowing for additional descriptions and relationships to exist between the runes.

Usage

sx(
  x = unspecified(),
  role = list(),
  tier = list(),
  label = list(),
  pattern = character(),
  ...
)

cast_spell(
  x = unspecified(),
  role = list(),
  tier = list(),
  label = list(),
  pattern = character(),
  ...
)

Arguments

x

Objects of the following types can be used as inputs

  • rune

  • formula

role

Specific roles the variable plays within the formula. These are of particular importance, as they serve as special terms that can effect how a formula is interpreted. Please see the Roles section below for further details. The options for roles are as below:

  • outcome: outcome/dependent variable that serves as an individual variable in the exposure -> outcome relationship (DEFAULT for LHS variables)

  • predictor: predictors of the outcomes (DEFAULT for RHS variables)

  • exposure: predictor variable that serves as a primary or key variable in the exposure -> outcome relationship

  • confounder: predictor variable that is thought to be a confounder of the causal relationship in the exposure <- confounder -> outcome pathway, normally thought of as an adjustment or controlling variable

  • mediator: predictor variable that is thought to be a causal intermediary in the exposure -> mediator -> outcome pathway

  • interaction: predictor variable that is proposed as an interaction term with a exposure variable, and currently only supported if exposure variables are declared

  • unknown: default role of a variable that has not yet been assigned a place, such as a potential intermediary object

tier

Grouping variable names for covariates or confounders for modeling terms together

label

Display-quality label describing the variable

pattern

This is the expansion pattern used to decide how the covariates will incorporated into the formulas. The options are c("direct", "sequential", "parallel"). See the details for further explanation.

  • direct: the covariates will all be included in each formula

  • sequential: the covariates will be added sequentially, one by one, or by tiers, as indicated

  • parallel: the covariates or tiers of covariates will be placed in parallel

...

Arguments to be passed to or from other methods

Value

An object of class spell

Roles

Specific roles the variable plays within the formula. These are of particular importance, as they serve as special runes that can effect how a formula is interpreted. The specialized options for roles are as below:

  • exposure or X(...)

  • outcome or O(...) or placement of variable on LHS of formula

  • confounder or C(...)

  • mediator or M(...)

  • strata or S(...)

  • interaction or In()

Formulas can be condensed by applying their specific role to individual runes as a function/wrapper. For example, y ~ X(x1) + x2 + x3. This would signify that x1 has the specific role of an exposure.

Patterns

The expansion pattern allows for instructions on how the covariates should be included in different formulas. Below, assuming that x1, x2, and x3 are covariates...

y ~ x1 + x2 + x3

Direct:

y ~ x1 + x2 + x3

Seqential:

y ~ x1

y ~ x1 + x2

y ~ x1 + x2 + x3

Parallel:

y ~ x1

y ~ x2

y ~ x3

Pluralized Arguments

For the arguments that would be dispatched for objects that are plural, e.g. containing multiple terms such as a formula object, the input should be wrapped within a list().

For example, for the role argument, it would be written:

role = list(X ~ "exposure", M ~ "mediator", C ~ "confounder")

This applies for all others plural objects and arguments.


asshah4/forks documentation built on Nov. 12, 2022, 3:43 a.m.