Skip to contents

This function detects categorical variables based on reference labels in a glmmTMB object's frame.

Usage

detect_categoricals_vars(tmb_frame, ref_labels)

Arguments

tmb_frame

The data frame of a glmmTMB object.

ref_labels

Vector of reference labels corresponding to categorical variables.

Value

Names of the categorical variables detected.

Examples

data("mtcars")
## -- specify categorical var
mtcars$vs <- factor(mtcars$vs) ## Engine (0 = V-shaped, 1 = straight)
levels(mtcars$vs) <- c("V-shaped", "straight")
mtcars$am <- factor(mtcars$am) ## Transmission (0 = automatic, 1 = manual)
levels(mtcars$am) <- c("automatic", "manual")
## -- For each group of number of cylinder,
## -- explain fuel consumption with engine shape, Gross horsepower,  and transmission type
list_tmb <- fitModelParallel(formula = mpg ~ hp + vs + am, 
                 data = mtcars, group_by = "cyl" , n.cores = 1)
#> Log file location: /tmp/RtmpS86cq0/htrfit.log
#> CPU(s) number : 1
#> Cluster type : PSOCK
detect_categoricals_vars(list_tmb[["6"]]$frame, c("straight", "manual"))
#> [1] "vs" "am"