Relevels factors in a list of glmmTMB objects using specified reference labels.
relevelling_factors.Rd
This function re-levels factors in a list of glmmTMB objects based on the specified reference labels.
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
relevelling_factors(list_tmb , c("straight", "manual"))
#> $`6`
#> Formula: mpg ~ hp + vs + am
#> Data: data
#> AIC BIC logLik df.resid
#> 28.46985 28.25349 -10.23492 3
#>
#> Number of obs: 7
#>
#> Dispersion estimate for gaussian family (sigma^2): 1.09
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept) hp vsstraight ammanual
#> 23.46038 -0.02198 -1.80247 NA
#>
#> $`4`
#> Formula: mpg ~ hp + vs + am
#> Data: data
#> AIC BIC logLik df.resid
#> 64.87146 66.86093 -27.43573 6
#>
#> Number of obs: 11
#>
#> Dispersion estimate for gaussian family (sigma^2): 8.59
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept) hp vsstraight ammanual
#> 30.3509 -0.1033 1.2943 5.0484
#>
#> $`8`
#> NULL
#>