create_formulas: Create formulas for all possible combinations of variables

Description Usage Arguments Value Examples

View source: R/formula-parser.R

Description

Creates formulas for all possible combinations of variables provided to the function. All terms can appear as linear terms or non-linear terms.

Usage

1
create_formulas(num_vars, cat_vars, lhs, fname = NULL)

Arguments

num_vars

A character vector of covariates on numeric scale.

cat_vars

A character vector of categorical covariates

lhs

The left-hand side of the formula to be produced.

fname

A string of the special function in which x will be wrapped in. Defaults to "rcs"

Value

A vector of formula strings for possible (and correct) model specifications given the variables provided.

Examples

1
2
3
4
5
6
7
create_formulas(num_vars = c("x1", "x2"), lhs = "Surv(time, status) ~")
create_formulas(num_vars = c("x1", "x2"), cat_vars = c("z1"),
 lhs = "Surv(time, status) ~")
create_formulas(num_vars = c("x1"), cat_vars = c("z1", "pspline(x2)"),
 lhs = "Surv(time, status) ~")
create_formulas(num_vars = c("x1", "x2"), cat_vars = c("z1"),
 lhs = "Surv(time, status) ~", fname = "psline")

adibender/ldatools documentation built on March 7, 2020, 5:30 a.m.