# Formatted Correlation with Effect Size

**Dominique Makowski**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

- Do a correlation
- APA formatted output
- Dataframe of Values
- Bayesian Correlation
- Contribute
- Credits
- Previous blogposts

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 increase de variability of statistical reporting. At the sime time, standardizing practices of what and how to report is crucial for reproducibility and clarity. **The psycho package was designed specifically to do this job**, at first for complex Bayesian mixed models, but is now also compatible with basic methods, such as **correlation**.

# Do a correlation

```
<span class="n">df</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">iris</span><span class="w"> </span><span class="c1"># Load the traditional iris dataset into an object called df (for dataframe)</span><span class="w">
</span><span class="n">cor_results</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">cor.test</span><span class="p">(</span><span class="n">df</span><span class="o">$</span><span class="n">Sepal.Length</span><span class="p">,</span><span class="w"> </span><span class="n">df</span><span class="o">$</span><span class="n">Petal.Length</span><span class="p">)</span><span class="w"> </span><span class="c1"># Compute a correlation and store its result</span><span class="w">
</span>
```

# APA formatted output

```
<span class="c1"># devtools::install_github("neuropsychology/psycho.R") # Install the latest psycho version</span><span class="w">
</span><span class="n">library</span><span class="p">(</span><span class="n">psycho</span><span class="p">)</span><span class="w"> </span><span class="c1"># Load the psycho package</span><span class="w">
</span><span class="n">psycho</span><span class="o">::</span><span class="n">analyze</span><span class="p">(</span><span class="n">cor_results</span><span class="p">)</span><span class="w"> </span><span class="c1"># Run the analyze function on the correlation</span><span class="w">
</span>
```

`The Pearson's product-moment correlation between df$Sepal.Length and df$Petal.Length is significantly large and positive (r(148) = 0.87, 95% CI [0.83, 0.91], p < .001).`

The formatted output includes the **direction**, **effect size** (interpreted by default with **Cohen’s (1988)** rules of thumb) and **confidence intervals**. Now, you can just copy and paste this line into your report and focus on more important things than formatting.

# Dataframe of Values

It is also possible to have all the values stored in a dataframe by running a **summary** on the analyzed object.

```
<span class="n">results</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">analyze</span><span class="p">(</span><span class="n">cor_results</span><span class="p">)</span><span class="w">
</span><span class="n">summary</span><span class="p">(</span><span class="n">results</span><span class="p">)</span><span class="w">
</span>
```

effect | statistic | df | p | CI_lower | CI_higher |
---|---|---|---|---|---|

0.872 | 21.646 | 148 | 0 | 0.827 | 0.906 |

# Bayesian Correlation

Nevertheless, we recommand doing a **Bayesian correlation**, which is even easier and quicker to do!

# Contribute

Of course, these reporting standards are bound to change, depending on new expert recommandations or official guidelines. **The goal of this package is to flexibly accompany new changes and good practices evolution**. Therefore, if you have any advices, opinions or such, we encourage you to either let us know by opening an issue or, *even better*, try to implement them yourself by contributing to the code.

# Credits

This package helped you? Don’t forget to cite the various packages you used 🙂

You can cite `psycho`

as follows:

- Makowski, (2018).
*The psycho Package: An Efficient and Publishing-Oriented Workflow for Psychological Science*. Journal of Open Source Software, 3(22), 470. https://doi.org/10.21105/joss.00470

# Previous blogposts

- Extracting a Reference Grid of your Data for Machine Learning Models Visualization
- Copy/paste t-tests Directly to Manuscripts
- Easy APA Formatted Bayesian Correlation
- Fancy Plot (with Posterior Samples) for Bayesian Regressions
- How Many Factors to Retain in Factor Analysis
- Beautiful and Powerful Correlation Tables
- Format and Interpret Linear Mixed Models
- How to do Repeated Measures ANOVAs
- Standardize (Z-score) a dataframe
- Compute Signal Detection Theory Indices
- Installing R, R Studio and psycho

**leave a comment**for the author, please follow the link and comment on their blog:

**Dominique Makowski**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.