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 frequentist models in Bernabeu (2022; the table for Bayesian models is covered in this other post). The sample table presents a mixed-effects model that was fitted using the R package lmerTest
(Kuznetsova 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 frequentist coefficients (estimates and confidence intervals) KR_summary_semanticpriming_lmerTest = readRDS(gzcon(url('https://github.com/pablobernabeu/language-sensorimotor-simulation-PhD-thesis/blob/main/semanticpriming/frequentist_analysis/results/KR_summary_semanticpriming_lmerTest.rds?raw=true'))) confint_semanticpriming_lmerTest = readRDS(gzcon(url('https://github.com/pablobernabeu/language-sensorimotor-simulation-PhD-thesis/blob/main/semanticpriming/frequentist_analysis/results/confint_semanticpriming_lmerTest.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 lmerTest
summary and in the confidence intervals object.
Incidentally, the confidence intervals were obtained using the confint.merMod
function from the lme4
package, as neither lmerTest
nor lme4
currently provide confidence intervals in their default results output. However, computing the confidence intervals is uncomplicated (see code).
# 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 'frequentist_model_table' # function that the two terms in the interaction must be split # into two lines. rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_attentional_control'] = 'Attentional control' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_vocabulary_size'] = 'Vocabulary size <sup>a</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_participant_gender'] = 'Gender <sup>a</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_target_word_frequency'] = 'Word frequency' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_target_number_syllables'] = 'Number of syllables' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_word_concreteness_diff'] = 'Word-concreteness difference' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_cosine_similarity'] = 'Language-based similarity <sup>b</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_visual_rating_diff'] = 'Visual-strength difference <sup>b</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_interstimulus_interval'] = 'Stimulus onset asynchrony (SOA) <sup>b</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_word_concreteness_diff:z_vocabulary_size'] = 'Word-concreteness difference :: Vocabulary size' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_word_concreteness_diff:z_recoded_interstimulus_interval'] = 'Word-concreteness difference : SOA' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_word_concreteness_diff:z_recoded_participant_gender'] = 'Word-concreteness difference : Gender' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_attentional_control:z_cosine_similarity'] = 'Language-based similarity :: Attentional control' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_attentional_control:z_visual_rating_diff'] = 'Visual-strength difference :: Attentional control' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_vocabulary_size:z_cosine_similarity'] = 'Language-based similarity :: Vocabulary size' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_vocabulary_size:z_visual_rating_diff'] = 'Visual-strength difference :: Vocabulary size' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_participant_gender:z_cosine_similarity'] = 'Language-based similarity : Gender' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_participant_gender:z_visual_rating_diff'] = 'Visual-strength difference : Gender' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_interstimulus_interval:z_cosine_similarity'] = 'Language-based similarity : SOA <sup>b</sup>' rownames(KR_summary_semanticpriming_lmerTest$coefficients)[ rownames(KR_summary_semanticpriming_lmerTest$coefficients) == 'z_recoded_interstimulus_interval:z_visual_rating_diff'] = 'Visual-strength difference : SOA <sup>b</sup>' # Next, change the names in the confidence intervals object rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_attentional_control'] = 'Attentional control' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_vocabulary_size'] = 'Vocabulary size <sup>a</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_participant_gender'] = 'Gender <sup>a</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_target_word_frequency'] = 'Word frequency' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_target_number_syllables'] = 'Number of syllables' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_word_concreteness_diff'] = 'Word-concreteness difference' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_cosine_similarity'] = 'Language-based similarity <sup>b</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_visual_rating_diff'] = 'Visual-strength difference <sup>b</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_interstimulus_interval'] = 'Stimulus onset asynchrony (SOA) <sup>b</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_word_concreteness_diff:z_vocabulary_size'] = 'Word-concreteness difference :: Vocabulary size' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_word_concreteness_diff:z_recoded_interstimulus_interval'] = 'Word-concreteness difference : SOA' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_word_concreteness_diff:z_recoded_participant_gender'] = 'Word-concreteness difference : Gender' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_attentional_control:z_cosine_similarity'] = 'Language-based similarity :: Attentional control' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_attentional_control:z_visual_rating_diff'] = 'Visual-strength difference :: Attentional control' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_vocabulary_size:z_cosine_similarity'] = 'Language-based similarity :: Vocabulary size' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_vocabulary_size:z_visual_rating_diff'] = 'Visual-strength difference :: Vocabulary size' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_participant_gender:z_cosine_similarity'] = 'Language-based similarity : Gender' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_participant_gender:z_visual_rating_diff'] = 'Visual-strength difference : Gender' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_interstimulus_interval:z_cosine_similarity'] = 'Language-based similarity : SOA <sup>b</sup>' rownames(confint_semanticpriming_lmerTest)[ rownames(confint_semanticpriming_lmerTest) == 'z_recoded_interstimulus_interval:z_visual_rating_diff'] = 'Visual-strength difference : SOA <sup>b</sup>'
frequentist_model_table()
The following custom function was used.