% Generated by roxygen2: do not edit by hand % Please edit documentation in R/update_fittedmodel.R \name{updateParallel} \alias{updateParallel} \title{Update glmmTMB models in parallel.} \usage{ updateParallel( formula, list_tmb, reference_labels = c(), n.cores = NULL, cl_type = "PSOCK", log_file = paste(tempdir(check = FALSE), "htrfit.log", sep = "/"), ... ) } \arguments{ \item{formula}{Formula for the GLMNB model.} \item{list_tmb}{List of glmmTMB objects.} \item{reference_labels}{Vector of reference labels. Default is c(), selecting the first alphanumeric label as reference.} \item{n.cores}{Number of cores to use for parallel processing. If NULL, the function will use all available cores.} \item{cl_type}{cluster type (default "PSOCK"). "FORK" is recommended for linux.} \item{log_file}{File path for the log output (default: Rtmpdir/htrfit.log).} \item{...}{Additional arguments to be passed to the glmmTMB::glmmTMB function.} } \value{ A list of updated GLMNB models. } \description{ This function updates glmmTMB models in parallel using multiple cores, allowing for faster computation. It updates the models with new reference labels if specified. It can also be used to fit a new formula or to change additional parameters of glmmTMB (param : "..."). } \examples{ # -- Example usage: update formula data(iris) groups <- unique(iris$Species) group_by <- "Species" formula <- Sepal.Length ~ Sepal.Width + Petal.Length fitted_models <- fitModelParallel(formula, iris, group_by, n.cores = 1) new_formula <- Sepal.Length ~ Sepal.Width results <- updateParallel(new_formula, fitted_models, n.cores = 1) # Example usage: update reference # -- Load the mtcars dataset data("mtcars") # -- Specify categorical variables 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 cylinders: # -- 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) # -- Relevel transmission and engine shape variables list_tmb <- updateParallel(formula = mpg ~ hp + vs + am, list_tmb, reference_labels = c("straight", "manual"), n.cores = 1) }