Conducting and Visualizing Specification Curve Analyses

CRAN status CRAN downloads Lifecycle: stable R-CMD-check


What is specr?

The goal of specr is to facilitate specification curve analyses (Simonsohn, Simmons & Nelson, 2020; also known as multiverse analyses, see Steegen, Tuerlinckx, Gelman & Vanpaemel, 2016). The package can be used to investigate how different (theoretically plausible) analytical choices affect outcome statistics within the universe of one single data set. It provides functions to setup, run, evaluate, and plot the multiverse of specifications. A simple example of how to use specr is provided below. For more information about the various functions and specific vignettes and use cases, visit the documentation.


We do see a lot of value in investigating how analytical choices affect a statistical outcome of interest. However, we strongly caution against using specr as a tool to somehow arrive at a better estimate. Running a specification curve analysis does not make your findings any more reliable, valid or generalizable than a single analysis. The method is only meant to inform about the effects of analytical choices on results, and not a better way to estimate a correlation or effect.


Install specr from CRAN:

install.packages("specr")   # version 0.2.1

Or install the most recent development version from GitHub with:

# install.packages("devtools")
devtools::install_github("masurp/specr")   # version 1.0.0


Using specr is comparatively simple. The two main function are setup(), in which analytic choices are specified as arguments, and specr(), which fits the models across all specifications. The latter creates a class called “specr.object”, which can be summarized and plotted with generic function such as summary or plot.

# Load package ----

# Setup Specifications ----
specs <- setup(data = example_data, 
               y = c("y1", "y2"), 
               x = c("x1", "x2"), 
               model = c("lm"),
               controls = c("c1", "c2"),
               subsets = list(group1 = unique(example_data$group1),
                              group2 = unique(example_data$group2)))

# Run Specification Curve Analysis ----
results <- specr(specs)

# Plot Specification Curve ----

How to cite this package

#> To cite 'specr' in publications use:
#>   Masur, Philipp K. & Scharkow, M. (2020). specr: Conducting and
#>   Visualizing Specification Curve Analyses. Available from
#>   https://CRAN.R-project.org/package=specr.
#> A BibTeX entry for LaTeX users is
#>   @Misc{,
#>     title = {specr: Conducting and Visualizing Specification Curve Analyses (Version 1.0.0)},
#>     author = {Philipp K. Masur and Michael Scharkow},
#>     year = {2020},
#>     url = {https://CRAN.R-project.org/package=specr},
#>   }


Papers that used ‘specr’

If you have published a paper in which you used specr and you would like to be included in the following list, please send an email to Philipp.