Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Here I share the format applied to tables presenting the results of Bayesian models in Bernabeu (2022; the table for frequentist models is covered in this other post). The sample table presents a Bayesian mixed-effects model that was fitted using the R package brms
(Bürkner et al., 2022). The mixed effects were driven by the maximal principle (Brauer & Curtin, 2018). The format of the table resembles one of the examples published by the American Psychological Association. However, there are also deviations from those examples. For instance, in the present table, the effects are grouped under informative labels to facilitate the readers’ comprehension, using the kableExtra
package (Zhu, 2022). Furthermore, the random slopes are specified using superscript letters and a footnote. The table can be reproduced using the materials at https://osf.io/gt5uf.
Loading packages and the results of the models
library(dplyr) library(knitr) library(tibble) library(stringr) library(lmerTest) library(kableExtra) # Load Bayesian results summary semanticpriming_summary_weaklyinformativepriors_exgaussian = readRDS(gzcon(url('https://github.com/pablobernabeu/language-sensorimotor-simulation-PhD-thesis/blob/main/semanticpriming/bayesian_analysis/results/semanticpriming_summary_weaklyinformativepriors_exgaussian.rds?raw=true')))
Adjusting the names of the effects
First, to facilitate the understanding of the results, the original names of the effects will be adjusted in the brms
summary.
# Rename effects in plain language and specify the random slopes # (if any) for each effect, in the footnote. For this purpose, # superscripts are added to the names of the appropriate effects. # # In the interactions below, word-level variables are presented # first for the sake of consistency (the order does not affect # the results in any way). Also in the interactions, double # colons are used to inform the 'bayesian_model_table' # function that the two terms in the interaction must be split # into two lines. rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_attentional_control'] = 'Attentional control' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_attentional_control'] = 'Attentional control' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_vocabulary_size'] = 'Vocabulary size <sup>a</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_recoded_participant_gender'] = 'Gender <sup>a</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_target_word_frequency'] = 'Word frequency' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_target_number_syllables'] = 'Number of syllables' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_word_concreteness_diff'] = 'Word-concreteness difference' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_cosine_similarity'] = 'Language-based similarity <sup>b</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_visual_rating_diff'] = 'Visual-strength difference <sup>b</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_recoded_interstimulus_interval'] = 'Stimulus onset asynchrony (SOA) <sup>b</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_word_concreteness_diff:z_vocabulary_size'] = 'Word-concreteness difference :: Vocabulary size' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_word_concreteness_diff:z_recoded_interstimulus_interval'] = 'Word-concreteness difference : SOA' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_word_concreteness_diff:z_recoded_participant_gender'] = 'Word-concreteness difference : Gender' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_attentional_control:z_cosine_similarity'] = 'Language-based similarity :: Attentional control' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_attentional_control:z_visual_rating_diff'] = 'Visual-strength difference :: Attentional control' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_vocabulary_size:z_cosine_similarity'] = 'Language-based similarity :: Vocabulary size' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_vocabulary_size:z_visual_rating_diff'] = 'Visual-strength difference :: Vocabulary size' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_recoded_participant_gender:z_cosine_similarity'] = 'Language-based similarity : Gender' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_recoded_participant_gender:z_visual_rating_diff'] = 'Visual-strength difference : Gender' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_cosine_similarity:z_recoded_interstimulus_interval'] = 'Language-based similarity : SOA <sup>b</sup>' rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed)[ rownames(semanticpriming_summary_weaklyinformativepriors_exgaussian$fixed) == 'z_visual_rating_diff:z_recoded_interstimulus_interval'] = 'Visual-strength difference : SOA <sup>b</sup>'
bayesian_model_table()
This custom function was used in Bernabeu (2022), with a PDF output. In the current scenario, however, we have an HTML output. In the above function, the code used for the \(\widehat{R}\) tailored to the HTML output (&Rcirc;
) does not render properly.