Skip to contents

Builds a multi-level categorical covariate definition list.

Usage

covar_categorical(name, probs, labels = NULL)

Arguments

name

Column name in the generated data.

probs

Numeric vector of category probabilities (must sum to 1).

labels

Optional character vector of level labels. Length must equal length(probs). Defaults to "1", "2", ...

Value

A named list suitable as one element of the covariates argument.

Examples

covar_categorical("stage", probs = c(0.4, 0.35, 0.25),
                  labels = c("I", "II", "III"))
#> $name
#> [1] "stage"
#> 
#> $type
#> [1] "categorical"
#> 
#> $dist
#> [1] "categorical"
#> 
#> $params
#> $params$prob
#> [1] 0.40 0.35 0.25
#> 
#> $params$labels
#> [1] "I"   "II"  "III"
#> 
#>