Programmatic way of constructing model formulas

create_formula(
  dat,
  outcome,
  exposure,
  covariates,
  id_var,
  method,
  add_inter_exposure,
  add_inter_exposure_specific,
  add_splines_exposure,
  df_splines,
  threshold_smooth,
  threshold_k
)

Arguments

dat

A dataframe containing the variables of interest. A dataframe.

outcome

A string indicating the outcome variable. A string.

exposure

A string indicating the exposure variable. A string.

covariates

A list of covariate names. A vector.

id_var

The variable name to be used to identify subjects. A string.

method

The name of the model to be fitted (e.g., glm). A string.

add_inter_exposure

Whether to add an interaction between the exposure and all the covariates. A bool.

add_inter_exposure_specific

A list of covariate names for which an interaction with the exposure is desired. A vector.

add_splines_exposure

Whether to model the exposure with natural splines. A bool.

df_splines

The degrees of freedom for the natural splines. An integer.

threshold_smooth

For GAMs, threshold for the number of unique values of continuous variables. If the number of unique values is greater or equal than this variable, the dimension of the basis used to represent the smooth term (k), is chosen automatically. An integer.

threshold_k