combine_rds_fits
checks brmsfit objects saved as RDS files.
combine_rds_fits(path, dest.path = ".", save = TRUE, name = NULL, overwrite = FALSE,
suffix = "-combined_model", check.data = TRUE, verbose = TRUE, summary = FALSE, ...)
Directory in which to look for .rds files. Required.
Directory in which to save the combined fit as a RDS file (if save = TRUE
). Default is the current working directory.
Logical to control if the combined fit is saved as a RDS file.
Character string with the name of RDS file to be saves (when save = TRUE
)..
Logical to control if the RDS file is overwritten (when save = TRUE
).
Character string with a suffix to be added to the file name (when save = TRUE
). Default is "-combined_model".
Logical. Controls if the data should be checked for being the same across models (as in brm
).
Logical to control if messages are printed into the console.
Logical to control if a summary of the combined model is also saved. If TRUE extended_summary
is used.
Additional arguments to be passed to extended_summary
for further customizing summary.
If save = TRUE
the combined fit is save as a RDS file, otherwise the function returns a brmsfit object.
The function takes several brms models stored as RDS files and combine them in a single model. By default the combined model is saved as a RDS file, but it can instead be returned as an object (if save = FALSE
). If not supplied the name is obtained from the containing folder.
Araya-Salas (2022), brmsish: miscellaneous functions to customize brms bayesian regression models. R package version 1.0.0.Paul-Christian Buerkner (2017). brms: An R Package for Bayesian Multilevel Models Using Stan. Journal of Statistical Software, 80(1), 1-28. doi:10.18637/jss.v080.i01
{
# create directory
dir.create(file.path(tempdir(), "rdss"))
# run 2 models
md1 <- brm(Petal.Length ~ Petal.Width + Species, iris, chains = 1,
iter = 500, file = file.path(tempdir(), "rdss", "md1"))
md2 <- brm(Petal.Length ~ Species, iris, chains = 1, iter = 500,
file = file.path(tempdir(), "rdss", "md2"))
# check fits
combine_rds_fits(path = file.path(tempdir(), "rdss"))
}
#> Warning: '/tmp/RtmpbELMrV/rdss' already exists
#> Compiling Stan program...
#> Error in .fun(model_code = .x1): Boost not found; call install.packages('BH')