Fit models in parallel for each group using mclapply and handle logging. Uses parallel_fit to fit the models.
fitModelParallel.Rd
Fit models in parallel for each group using mclapply and handle logging. Uses parallel_fit to fit the models.
Arguments
- formula
Formula specifying the model formula
- data
Data frame containing the data
- group_by
Column name in data representing the grouping variable
- n.cores
The number of CPU cores to use for parallel processing. If set to NULL (default), the number of available CPU cores will be automatically detected.
- cl_type
cluster type (default "PSOCK"). "FORK" is recommended for linux.
- log_file
File path to save the log messages (default : Rtmpdir/htrfit.log)
- ...
Additional arguments to be passed to the glmmTMB::glmmTMB function
Examples
fitModelParallel(formula = Sepal.Length ~ Sepal.Width + Petal.Length,
data = iris, group_by = "Species", n.cores = 1)
#> Log file location: /tmp/RtmpS86cq0/htrfit.log
#> CPU(s) number : 1
#> Cluster type : PSOCK
#> $setosa
#> Formula: Sepal.Length ~ Sepal.Width + Petal.Length
#> Data: data
#> AIC BIC logLik df.resid
#> 2.38185 10.02994 2.80907 46
#>
#> Number of obs: 50
#>
#> Dispersion estimate for gaussian family (sigma^2): 0.0523
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept) Sepal.Width Petal.Length
#> 2.3037 0.6674 0.2834
#>
#> $versicolor
#> Formula: Sepal.Length ~ Sepal.Width + Petal.Length
#> Data: data
#> AIC BIC logLik df.resid
#> 38.88241 46.53050 -15.44120 46
#>
#> Number of obs: 50
#>
#> Dispersion estimate for gaussian family (sigma^2): 0.109
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept) Sepal.Width Petal.Length
#> 2.1164 0.2476 0.7356
#>
#> $virginica
#> Formula: Sepal.Length ~ Sepal.Width + Petal.Length
#> Data: data
#> AIC BIC logLik df.resid
#> 31.94600 39.59409 -11.97300 46
#>
#> Number of obs: 50
#>
#> Dispersion estimate for gaussian family (sigma^2): 0.0945
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept) Sepal.Width Petal.Length
#> 0.6248 0.2600 0.9348
#>