layout: post title: "Copy/paste t-tests Directly to Manuscripts" author: Dominique Makowski author_web: https://dominiquemakowski.github.io/ date: 2018-06-19 summary: APA formatting for t-tests.
One of the most time-consuming part of data analysis in psychology is the copy-pasting of specific values of some R output to a manuscript or a report. This task is frustrating, prone to errors, and increases the variability of statistical reporting. This is an important issue, as standardizing practices of what and how to report might be a key to overcome the reproducibility crisis of psychology. The psycho package was designed specifically to do this job. At first, for complex Bayesian mixed models, but the package is now compatible with basic methods, such as t-tests.
# Load packages
library(tidyverse)
# devtools::install_github("neuropsychology/psycho.R") # Install the latest psycho version
library(psycho)
df <- psycho::affective # Load the data
results <- t.test(df$Age ~ df$Sex) # Perform a simple t-test
You simply run the analyze()
function on the t-test object.
psycho::analyze(results)
The Welch Two Sample t-test suggests that the difference of df$Age by df$Sex (mean in group F = 26.78, mean in group M = 27.45, difference = -0.67) is not significant (t(360.68) = -0.86, 95% CI [-2.21, 0.87], p > .1).
It works for all kinds of different t-tests versions.
t.test(df$Adjusting ~ df$Sex,
var.equal=TRUE,
conf.level = .90) %>%
psycho::analyze()
The Two Sample t-test suggests that the difference of df$Adjusting by df$Sex (mean in group F = 3.72, mean in group M = 4.13, difference = -0.41) is significant (t(1249) = -4.13, 90% CI [-0.58, -0.25], p < .001).
t.test(df$Adjusting,
mu=0,
conf.level = .90) %>%
psycho::analyze()
The One Sample t-test suggests that the difference between df$Adjusting (mean = 3.80) and mu = 0 is significant (t(1250) = 93.93, 90% CI [3.74, 3.87], p < .001).
It is also possible to have all the values stored in a dataframe by running a summary on the analyzed object.
library(tidyverse)
t.test(df$Adjusting ~ df$Sex) %>%
psycho::analyze() %>%
summary()
| effect| statistic| df| p| CI_lower| CI_higher| |-----------:|----------:|---------:|--------:|-----------:|-----------:| | -0.4149661| -4.067008| 377.8364| 5.8e-05| -0.6155884| -0.2143439|
Of course, these reporting standards should change, depending on new expert recommandations or official guidelines. The goal of this package is to flexibly adapt to new changes and accompany the evolution of best practices. Therefore, if you have any advices, opinions or ideas, we encourage you to let us know by opening an issue or, even better, to try to implement changes yourself by contributing to the code.
This package helped you? Don't forget to cite the various packages you used :)
You can cite psycho
as follows:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.