library(knitr)
You find it time-consuming to manually format, copy and paste output values to your report or manuscript? That time is over: the psycho
package is here for you!
Let's take the example dataset included in the psycho
package.
library(psycho) library(tidyverse) df <- psycho::emotion %>% select(Participant_ID, Emotion_Condition, Subjective_Valence, Autobiographical_Link) summary(df)
Our dataframe (called df
) contains data from several participants, exposed to neutral and negative pictures (the Emotion_Condition
column). Each row corresponds to a single trial. During each trial, the participant had to rate its emotional valence (Subjective_Valence
: positive - negative) experienced during the picture presentation and the amount of personal memories associated with the picture (Autobiographical_Link
).
Our dataframe contains, for each of the 48 trials, 4 variables: the name of the participant (Participant_ID
), the emotion condition (Emotion_Condition
), the valence rating (Subjective_Valence
) and the Autobiographical Link (Autobiographical_Link
).
Let's fit a linear mixed model to predict the autobiographical link with the condition and the subjective valence.
library(lmerTest) fit <- lmer(Autobiographical_Link ~ Emotion_Condition * Subjective_Valence + (1|Participant_ID), data=df) summary(fit)
The analyze
function, available in the psycho
package, transforms a model fit object into user-friendly outputs.
results <- analyze(fit, CI = 95)
Summarizing an analyzed object returns a dataframe, that can be easily saved and included in reports. It also includes standardized coefficients, as well as bootstrapped confidence intervals (CI) and effect sizes.
summary(results) %>% mutate(p = psycho::format_p(p))
knitr::kable(summary(results) %>% mutate(p = psycho::format_p(p)), digits=2)
Moreover, the print
method return a nicely formatted output that can be almost directly pasted into the manuscript.
print(results)
The intercept (the baseline level) corresponds, here, to the negative condition with subjective valence at 0 (the average, as the data is standardized). Compared to that, changing the condition from negative to neutral does not induce any significant change to the outcome. However, in the negative condition, there is a trending linear relationship between valence and autobiographical memories: the more an item is positive the more it is related to memories. Finally, the interaction is significant: the relationship between valence autobiographical memories is stronger (more positive) in the neutral condition.
This package helped you? You can cite psycho
as follows:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.