Title: | Extract Statistics from Articles and Recompute P-Values |
---|---|
Description: | A "spellchecker" for statistics. It checks whether your p-values match their accompanying test statistic and degrees of freedom. statcheck searches for null-hypothesis significance test (NHST) in APA style (e.g., t(28) = 2.2, p < .05). It recalculates the p-value using the reported test statistic and degrees of freedom. If the reported and computed p-values don't match, statcheck will flag the result as an error. If the reported p-value is statistically significant and the recomputed one is not, or vice versa, the result will be flagged as a decision error. You can use statcheck directly on a string of text, but you can also scan a PDF or HTML file, or even a folder of PDF and/or HTML files. Statcheck needs an external program to convert PDF to text: Xpdf. Instructions on where and how to download this program, how to install statcheck, and more details on what statcheck can and cannot do can be found in the online manual: <https://rpubs.com/michelenuijten/statcheckmanual>. You can find a point-and-click web interface to scan PDF or HTML or DOCX articles on <http://statcheck.io>. |
Authors: | Michele B. Nuijten [aut, cre] |
Maintainer: | Michele B. Nuijten <[email protected]> |
License: | GPL-3 |
Version: | 1.6.0 |
Built: | 2025-02-21 04:30:42 UTC |
Source: | https://github.com/michelenuijten/statcheck |
These functions search for NHST results in PDF and/or HTML articles and send
the extracted statistics to statcheck
.
checkHTML(files, ...) checkPDF(files, ...)
checkHTML(files, ...) checkPDF(files, ...)
files |
Vector of strings containing file paths to HTML files to check. |
... |
Arguments sent to |
A statcheck data frame with the extracted statistics. See
statcheck
for details.
These functions search for NHST results in all PDF and/or HTML articles in a
certain folder and send the extracted statistics to statcheck
.
checkHTMLdir(dir, subdir = TRUE, extension = TRUE, ...) checkPDFdir(dir, subdir = TRUE, ...) checkdir(dir, subdir = TRUE, ...)
checkHTMLdir(dir, subdir = TRUE, extension = TRUE, ...) checkPDFdir(dir, subdir = TRUE, ...) checkdir(dir, subdir = TRUE, ...)
dir |
String indicating the directory to be used. If this is left empty, a window will pop up from which you can choose a directory. |
subdir |
Logical. Indicates whether you also want to check subfolders. Defaults to TRUE |
extension |
Logical. Indicates whether the HTML extension should be checked. Defaults to TRUE |
... |
Arguments sent to |
A statcheck data frame with the extracted statistics. See
statcheck
for details.
With this function you can simply point and click on the datapoints in the plot to see the corresponding statcheck details, such as the paper from which the data came and the exact statistical results.
## S3 method for class 'statcheck' identify(x, alpha = 0.05, ...)
## S3 method for class 'statcheck' identify(x, alpha = 0.05, ...)
x |
A statcheck object. See |
alpha |
assumed level of significance in the scanned texts. Defaults to .05. |
... |
arguments to be passed to methods, such as graphical parameters
(see |
## Not run: # First we need a statcheck object # Here, we create one by running statcheck on some raw text txt <- "This test is consistent t(28) = 0.2, p = .84, but this one is inconsistent: F(2, 28) = 4.2, p = .01. This final test is even a gross/decision inconsistency: z = 1.23, p = .03" result <- statcheck(txt) # Now, we can run identify.statcheck(), or shorter, simply identify(): identify(result) # Further instructions: # click on one or multiple points of interest # press Esc # a dataframe with information on the selected points will appear ## End(Not run)
## Not run: # First we need a statcheck object # Here, we create one by running statcheck on some raw text txt <- "This test is consistent t(28) = 0.2, p = .84, but this one is inconsistent: F(2, 28) = 4.2, p = .01. This final test is even a gross/decision inconsistency: z = 1.23, p = .03" result <- statcheck(txt) # Now, we can run identify.statcheck(), or shorter, simply identify(): identify(result) # Further instructions: # click on one or multiple points of interest # press Esc # a dataframe with information on the selected points will appear ## End(Not run)
Function for plotting of statcheck
objects. Reported p values are
plotted against recalculated p values, which allows the user to easily spot
if articles contain miscalculations of statistical results.
## S3 method for class 'statcheck' plot(x, alpha = 0.05, APAstyle = TRUE, group = NULL, ...)
## S3 method for class 'statcheck' plot(x, alpha = 0.05, APAstyle = TRUE, group = NULL, ...)
x |
A statcheck object. See |
alpha |
assumed level of significance in the scanned texts. Defaults to .05. |
APAstyle |
If TRUE, prints plot in APA style. |
group |
Indicate grouping variable to facet plot. Only works when
|
... |
arguments to be passed to methods, such as graphical parameters
(see |
If APAstyle = FALSE, inconsistencies between the reported and the recalculated p value are indicated with an orange dot. Recalculations of the p value that render a previously non significant result (p >= .5) as significant (p < .05), and vice versa, are considered decision errors, and are indicated with a red dot. Exactly reported p values (i.e. p = ..., as opposed to p < ... or p > ...) are indicated with a diamond.
Many thanks to John Sakaluk who adapted the plot code to create graphs in APA style.
# First we need a statcheck object # Here, we create one by running statcheck on some raw text txt <- "This test is consistent t(28) = 0.2, p = .84, but this one is inconsistent: F(2, 28) = 4.2, p = .01. This final test is even a gross/decision inconsistency: z = 1.23, p = .03" result <- statcheck(txt) # We can then plot the statcheck object 'result' by simply calling plot() on # "result". R will know what kind of plot to make, because "result" is of # class "statcheck" plot(result)
# First we need a statcheck object # Here, we create one by running statcheck on some raw text txt <- "This test is consistent t(28) = 0.2, p = .84, but this one is inconsistent: F(2, 28) = 4.2, p = .01. This final test is even a gross/decision inconsistency: z = 1.23, p = .03" result <- statcheck(txt) # We can then plot the statcheck object 'result' by simply calling plot() on # "result". R will know what kind of plot to make, because "result" is of # class "statcheck" plot(result)
statcheck
extracts Null Hypothesis Significance (NHST) results from
strings and returns the extracted values, reported p-values and recomputed
p-values.
statcheck( texts, stat = c("t", "F", "cor", "chisq", "Z", "Q"), OneTailedTests = FALSE, alpha = 0.05, pEqualAlphaSig = TRUE, pZeroError = TRUE, OneTailedTxt = FALSE, AllPValues = FALSE, messages = TRUE )
statcheck( texts, stat = c("t", "F", "cor", "chisq", "Z", "Q"), OneTailedTests = FALSE, alpha = 0.05, pEqualAlphaSig = TRUE, pZeroError = TRUE, OneTailedTxt = FALSE, AllPValues = FALSE, messages = TRUE )
texts |
A vector of strings. |
stat |
Specify which test types you want to extract. "t" to extract
t-values, "F" to extract F-values, "cor" to extract correlations, "chisq"to
extract |
OneTailedTests |
Logical. Do you want to assume that all reported tests are one-tailed (TRUE) or two-tailed (FALSE, default)? |
alpha |
Assumed level of significance in the scanned texts. Defaults to .05. |
pEqualAlphaSig |
Logical. If TRUE, statcheck counts p <= alpha as significant (default), if FALSE, statcheck counts p < alpha as significant. |
pZeroError |
Logical. If TRUE, statcheck counts p = .000 as an error (because a p-value is never exactly zero, and should be reported as < .001), if FALSE, statcheck does not count p = .000 automatically as an error. |
OneTailedTxt |
Logical. If TRUE, statcheck searches the text for "one-sided", "one-tailed", and "directional" to identify the possible use of one-sided tests. If one or more of these strings is found in the text AND the result would have been correct if it was a one-sided test, the result is assumed to be indeed one-sided and is counted as correct. |
AllPValues |
Logical. If TRUE, the output will consist of a dataframe with all detected p values, also the ones that were not part of the full results in APA format. |
messages |
Logical. If TRUE, statcheck will print a progress bar while it's extracting statistics from text. |
statcheck
roughly works in three steps.
1. Scan text for statistical results
statcheck
uses regular expressions to recognizes statistical results
from t-tests, F-tests, -tests, Z-tests, Q-tests, and correlations.
statcheck can only recognize these results if the results are reported
exactly according to the APA guidelines:
t(df) = value, p = value
F(df1, df2) = value, p = value
r(df) = value, p = value
(df, N = value) = value, p = value
(N is optional)
Z = value, p = value
Q(df) = value, p = value (statcheck can distinguish between Q, Qw / Q-within, and Qb / Q-between)
statcheck
takes into account that test statistics and p values may be
exactly (=) or inexactly (< or >) reported. Different spacing has also been
taken into account.
2. Recompute p-value
statcheck
uses the reported test statistic and degrees of freedom to
recompute the p-value. By default, the recomputed p-value is two-sided
3. Compare reported and recomputed p-value
This comparison takes into account how the results were reported, e.g.,
p < .05 is treated differently than p = .05. Incongruent p values are marked
as an error
. If the reported result is significant and the recomputed
result is not, or vice versa, the result is marked as a
decision_error
.
Correct rounding is taken into account. For instance, a reported t-value of
2.35 could correspond to an actual value of 2.345 to 2.354 with a range of
p-values that can slightly deviate from the recomputed p-value.
statcheck
will not count cases like this as errors.
Note that when statcheck
flags an error
or
decision_error
, it implicitly assumes that the p-value is the
inconsistent value, but it could just as well be the case that the test
statistic or degrees of freedom contain a reporting error. statcheck
merely detects wether a set of numbers is consistent with each other.
A data frame containing for each extracted statistic:
Name of the file of which the statistic is extracted
Character indicating the statistic that is extracted
First degree of freedom (if applicable)
Second degree of freedom
Reported comparison of the test statistic, when importing from pdf this will often not be converted properly
Reported value of the statistic
Reported comparison, when importing from pdf this might not be converted properly
The reported p-value, or NA if the reported value was n.s.
The recomputed p-value
Raw string of the statistical reference that is extracted
The computed p value is not congruent with the reported p-value
The reported result is significant whereas the recomputed result is not, or vice versa.
Logical. Does the text contain the string "sided", "tailed", and/or "directional"?
What proportion of all detected p-values was part of a fully APA reported result?
For more details, see the online manual.
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" statcheck(txt)
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" statcheck(txt)
This function uses R Markdown to generate a nicely formatted HTML report of
statcheck
output.
statcheckReport(statcheckOutput, outputFileName, outputDir)
statcheckReport(statcheckOutput, outputFileName, outputDir)
statcheckOutput |
statcheck output of one of the following functions:
|
outputFileName |
String specifying the file name under which you want to save the generated HTML report. The extension ".html" is automatically added, so doesn't need to be specified in this argument. |
outputDir |
String specifying the directory in which you want to save the generated HTML report. |
This function temporarily saves the inserted statcheck
output as an
.RData file in the "output" folder in the statcheck package directory. This
file is then called by the .Rmd template that is saved in the folder "rmd",
also in the statcheck package directory. After the HTML report is generated,
the .RData file is removed again.
An HTML report, saved in the directory specified in the argument "outputDir".
## Not run: # first generate statcheck output, for instance by using the statcheck() function txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) # next, use this output to generate a nice HTML report of the results statcheckReport(stat, outputFileName="statcheckHTMLReport", outputDir="C:/mydocuments/results") # you can now find your HTML report in the folder # "C:/mydocuments/results" under the name "statcheckHTMLReport.html". ## End(Not run)
## Not run: # first generate statcheck output, for instance by using the statcheck() function txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) # next, use this output to generate a nice HTML report of the results statcheckReport(stat, outputFileName="statcheckHTMLReport", outputDir="C:/mydocuments/results") # you can now find your HTML report in the folder # "C:/mydocuments/results" under the name "statcheckHTMLReport.html". ## End(Not run)
Gives the summaries for a statcheck
object.
## S3 method for class 'statcheck' summary(object, ...)
## S3 method for class 'statcheck' summary(object, ...)
object |
a |
... |
additional arguments affecting the summary produced. |
A data frame containing for each source of statistics:
Name of the file/origin of which the statistics are extracted
The number of extracted reported p values per article
The number of errors per article
The number of decision errors per article
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) summary(stat)
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) summary(stat)
Returns a subset of columns of a statcheck
object.
trim(object, ...)
trim(object, ...)
object |
a |
... |
additional arguments affecting the trimmed output. |
A data frame containing for each source of statistics:
Name of the file/origin of which the statistics are extracted
Raw string of the statistical reference that is extracted
The recomputed p-value
The computed p value is not congruent with the reported p-value
The reported result is significant whereas the recomputed result is not, or vice versa.
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) trim(stat)
txt <- "blablabla the effect was very significant (t(100)=1, p < 0.001)" stat <- statcheck(txt) trim(stat)