<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/proofing-statistics-in-papers/"></div></div><div><a data-url="https://www.r-bloggers.com/proofing-statistics-in-papers/" data-counturl="https://www.r-bloggers.com/proofing-statistics-in-papers/" data-count="horizontal" data-text="Proofing statistics in papers" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2016/10/proofing-statistics-in-papers/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Recently saw a really fun article making the rounds: <a target="_blank" href="http://link.springer.com/article/10.3758%2Fs13428-015-0664-2"><em>The prevalence of statistical reporting errors in psychology (1985–2013)</em> Nuijten, M.B., Hartgerink, C.H.J., van Assen, M.A.L.M. et al. Behav Res (2015). doi:10.3758/s13428-015-0664-2</a>. The authors built an <a target="_blank" href="https://cran.r-project.org/">R</a> package to check psychology papers for statistical errors. Please read on for how that is possible, some tools, and commentary.</p>
<p><center><br>
<a target="_blank" href="https://en.wikipedia.org/wiki/Analytical_Engine"><br>
<img title="NewImage.png" alt="NewImage" src="https://i1.wp.com/www.win-vector.com/blog/wp-content/uploads/2016/10/NewImage.png?w=660" border="0" data-recalc-dims="1">
<p>
<blockquote><p>Early automated analysis:<br>
Trial model of a part of the Analytical Engine, built by Babbage, as displayed at the Science Museum (London) (Wikipedia).</p>
</blockquote>
<p><br>
<span></span></p></a>
<p>
<p>From the abstract of Nuijten et.al. paper we have:</p>
<blockquote><p>This study documents reporting errors in a sample of over 250,000 p-values reported in eight major psychology journals from 1985 until 2013, using the new R package “statcheck.” statcheck retrieved null-hypothesis significance testing (NHST) results from over half of the articles from this period. In line with earlier research, we found that half of all published psychology papers that use NHST contained at least one p-value that was inconsistent with its test statistic and degrees of freedom. One in eight papers contained a grossly inconsistent p-value that may have affected the statistical conclusion. </p>
</blockquote>
<p>How did they do that? Has science been so systematized it is finally mechanically reproducible? Did they get access to one of the new open information extraction systems (please see <a target="_blank" href="http://aiweb.cs.washington.edu/research/projects/aiweb/media/papers/etzioni-ijcai2011.pdf"><em>Open Information Extraction: the Second Generation</em> Oren Etzioni, Anthony Fader, Janara Christensen, Stephen Soderland, and Mausam</a> for some discussion)?</p>
<p>No, they used the fact that the American Psychological Association defines a formal style for reporting statistical significances, just like they define a formal style for citations. Roughly it looks for text like the following:</p>
<blockquote><p>The results of the regression indicated the two predictors explained 35.8% of the variance (R2=.38, F(2,55)=5.56, p &lt; .01).<br>
(From a <a target="_blank" href="https://web2.uconn.edu/writingcenter/pdf/Reporting_Statistics.pdf">derived style guide found at the University of Connecticut</a>.)
</p>
</blockquote>
<p>The software looks for fragments like: “(R2=.38, F(2,55)=5.56, p &lt; .01)”. So really we are looking at statistics in psychology papers because they have standards clear enough to facilitate inspection.</p>
<p>These statistical summaries are often put into research papers by cutting and pasting from multiple sources as not all stat packages report all these pieces in one contiguous string. So there are many chances for human error and therefore there is a very high chance they eventually get out of sync. Think of a researcher using Microsoft Word, Microsoft Excel, and some complicated graphical interface driven software again and again as data and treatment change throughout a study. Eventually something gets out of sync. We can try to check for inconsistency as both the reported p-value and R-squared are derivable from the <code>F(numdf,dendf)=Fvalue</code> portion.</p>
<p>In fact the cited example has errors. The “explained 35.8% of the variance” should likely be 38% (to match the R2 / coefficient of determination) <em>and</em> the “<code>F(2,55)=5.56</code>” bit would entail an R-squared closer to the following: <b>F Test</b> summary: (<i>R</i><sup>2</sup>=0.17, <i>F</i>(2,55)=5.56, <i>p</i>≤0.00632) (we chose to show the actual p-value, but cutting off at a sensible limit is part of the guidelines). Likely this is a <em>notional</em> example itself built by copying and pasting to show the format (so we have no intent of mocking it). We derived this result by writing our own R function that takes the F-summaries and re-calculates the R-squared and p-value. In our case we performed the calculation by pasting the following into R: “<code>formatAPAR2fromCite(numdf=2,dendf=55,FValue=5.56)</code>” which performs the calculation and formats the result close to APA style.</p>
<p>Really this helps point out <em>why</em> scientists should strongly prefer workflows that support reproducible research (a topic we teach using R, RStudio, knitr, Sweave, and optionally Latex). It would be better to have correct conclusions automatically transcribed into reports, instead of hoping to catch some fraction wrong ones later. This is one reason Charles Babbage specified a printer on both his Difference Engine 2 and Analytical Engine (circa 1847)- to avoid errors!</p>
<p>That being said we recommend reading the original paper. The ability to detect errors gives the ability to collect statistics on errors over time, so there<br>
are a number of interesting observations to be made. For more work in this spirit we suggest <a target="_blank" href="http://www.cs.tufts.edu/~nr/cs257/archive/don-knuth/empirical-fortran.pdf"><em>An empirical study of FORTRAN programs</em> Knuth, Donald E., Software: Practice and Experience, Vol. 1, No. 2, 1971, doi: 10.1002/spe.4380010203</a>.</p>
<p>We can even trying running <a target="_blank" href="https://cran.r-project.org/web/packages/statcheck/statcheck.pdf">statcheck</a> on the guide; it confirms the relation between the F-value and p-value and doesn’t seem to check the R-squared (probably not part of the intended check):</p>
<p><center><br>
<br>

<table border="1">
<tr>
<th>
</th>
<th>
x
</th>
</tr>
<tr>
<td align="right">
Source
</td>
<td>
1
</td>
</tr>
<tr>
<td align="right">
Statistic
</td>
<td>
F
</td>
</tr>
<tr>
<td align="right">
df1
</td>
<td>
2
</td>
</tr>
<tr>
<td align="right">
df2
</td>
<td>
55
</td>
</tr>
<tr>
<td align="right">
Test.Comparison
</td>
<td>
=
</td>
</tr>
<tr>
<td align="right">
Value
</td>
<td>
5.56
</td>
</tr>
<tr>
<td align="right">
Reported.Comparison
</td>
<td>
&lt;
</td>
</tr>
<tr>
<td align="right">
Reported.P.Value
</td>
<td>
0.01
</td>
</tr>
<tr>
<td align="right">
Computed
</td>
<td>
0.006321509
</td>
</tr>
<tr>
<td align="right">
Raw
</td>
<td>
F(2,55)=5.56, p &lt; .01
</td>
</tr>
<tr>
<td align="right">
Error
</td>
<td>
FALSE
</td>
</tr>
<tr>
<td align="right">
DecisionError
</td>
<td>
FALSE
</td>
</tr>
<tr>
<td align="right">
OneTail
</td>
<td>
FALSE
</td>
</tr>
<tr>
<td align="right">
OneTailedInTxt
</td>
<td>
FALSE
</td>
</tr>
<tr>
<td align="right">
APAfactor
</td>
<td>
1
</td>
</tr>
</table>
<p></p>
<p>Our R code demonstrating how to automatically produce ready to go APA style F-summaries can be found <a target="_blank" href="http://winvector.github.io/APAsig/APAsig.html">here</a>.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/proofing-statistics-in-papers/"></div></div><div><a data-url="https://www.r-bloggers.com/proofing-statistics-in-papers/" data-counturl="https://www.r-bloggers.com/proofing-statistics-in-papers/" data-count="vertical" data-text="Proofing statistics in papers" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.win-vector.com/blog/2016/10/proofing-statistics-in-papers/"> R – Win-Vector Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/ChLLlr4du-U"></a></div></center></center>