extended_summary prints a summary of brmsfit results.

extended_summary(
  fit = NULL,
  draws = NULL,
  gsub.pattern = NULL,
  gsub.replacement = NULL,
  xlab = "Effect size",
  ylab = "Parameter",
  n.posterior = 2000,
  fit.name = NULL,
  read.file = NULL,
  plot.area.prop = 1,
  remove.intercepts = FALSE,
  fill = "#6DCD59FF",
  trace.palette = viridis::viridis,
  effects = NULL,
  save = FALSE,
  dest.path = ".",
  overwrite = FALSE,
  robust = FALSE,
  width = 8,
  height = "dynamic",
  highlight = FALSE,
  print.name = TRUE,
  trace = TRUE,
  return = FALSE,
  spread.type = "MAD"
)

Arguments

fit

A brmsfit object.

draws

A draws object.

gsub.pattern

A vector with character strings to be replaced

gsub.replacement

A vector with character strings to use for replacement.

xlab

A character string with the horizontal axis label. Default is "Effect size".

ylab

A character string with the vertical axis label. Default is "Parameter".

n.posterior

Number of posterior samples to use for plotting. Default is 2000.

fit.name

Character string to be added as title. If not supplied and 'read.file' is supplied the name is obtained from the file.

read.file

Character string with the name of the .rds file containing the model fit.

plot.area.prop

Positive number to control de proportion of the plotting area of posterior distributions that will be included. Default is 1 (the default area included by ggplot). Useful for adding or removing empty space around distributions.

remove.intercepts

Logical to control if intercepts are included in the output.

fill

Color for posterior distribution fill. Default is "#6DCD59FF".

trace.palette

Color palette function for trace plotting. Default is viridis.

effects

Character vector with the name of the effects (e.g. predictor variables) to be included. Optional. Note that if effect names have been modified using 'gsub.pattern' and 'gsub.replacement' the modified names should be used instead. Effects in plots and tables will also be sorted as in 'effects' so this can be used to customize order.

save

Logical to control if the summary is saved instead of printed. If TRUE a RDS file with the function output (a list) and a jpeg file is saved into 'dest.path'.

dest.path

Directory in which to save results (if save = TRUE). The current working directory is used as default.

overwrite

Logical to control if saved results are overwritten. Defaul is FALSE.

robust

Logical to control the type of central tendency measure as in summary.brmsfit).

width

Width of posterior distribution + trace plots as in ggsave). Default is 8 (in).

height

Height of posterior distribution + trace plots as in ggsave). Default is 'dynamic' which means that the height will increase as more panels (predictors) are added.

highlight

Logical to control if posterior estimates for which the 95% credible intervals do not overlap with zero are highlighted. Default is FALSE.

print.name

Logical to control if the name of the model fit is printed (when plot = TRUE).

trace

Logical to control if chain trace plots are generated. Default is TRUE.

return

Logical to control if tables and plots are returned as a list instead of printed. Default is FALSE (printing tables and plots).

spread.type

Character string with the name of the method to quantify the spread of posterior distributions. Two options are available: "HPDI" (highest posterior density interval) and "MAD" (mean absolute deviation, default).

Value

If plot = TRUE the function returns a model fit table, a coefficient table and a posterior distribution halfeye graph. If save = TRUE this objects are saved as a RDS file along with jpeg file.

Details

It prints a summary of brmsfit results. It includes a model fit table, a coefficient table and a posterior distribution halfeye graph next to a chain trace plot. Tables are produce in html format so the output is nicely printed when knit in Rmarkdown files. You might have to add 'results = 'as.is' to chunk options in Rmarkdown documents.

References

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

See also

Author

Marcelo Araya-Salas marcelo.araya@ucr.ac.cr)

Examples

{
# run model
mod <- brm(Petal.Length ~ Petal.Width + Species, iris, chains = 1,
iter = 500, file = file.path(tempdir(), "mod"))

# print from fit
extended_summary(fit= mod)

# print summary reading the rds file
extended_summary(read.file = file.path(tempdir(), "mod.rds"))
}
#> Compiling Stan program...
#> Error in .fun(model_code = .x1): Boost not found; call install.packages('BH')