Reproducible Research

Course Schedule

source

Topics for leaders

  1. In what situations can a ‘reproducible example’ be useful?

Resource Presentations

Case Study Presentations - Let’s pick a winner!

Next Week’s Case Study

source

Final Projects

  • Refine your objectives:
    • answer 1-3 important questions OR
    • solve 1-3 important problems
  • Better to demonstrate 1-3 things well than 10 things poorly.

Brief note on colors…

source

Markdown & Quarto

Reproducible Research

“The goal of reproducible research is to tie specific instructions to data analysis and experimental data so that scholarship can be recreated, better understood, and verified.”

Max Kuhn, CRAN Task View: Reproducible Research

Philosphy

Remember, the data and code are real, the products (tables, figures) are ephemeral…

The Claerbout Principle

“An article about computational result is advertising, not scholarship. The actual scholarship is the full software environment, code and data, that produced the result.”

Claerbout and Karrenbach, Proceedings of the 62nd Annual International Meeting of the Society of Exploration Geophysics. 1992

Our work exists on a spectrum of reproducibility

alt text

Peng 2011, Science 334(6060) pp. 1226-1227

Goal: expose more of the research workflow

alt text

http://www.stodden.net/AMP2011/slides/pengslides.pdf

Common practices of many scientists

  1. Enter data in Excel
  2. Use Excel for data cleaning & descriptive statistics
  3. Use ArcGIS and use point-and-click options for processing / visualization
  4. Import data into SPSS/SAS/Stata for further analysis
  5. Use point-and-click options to run statistical analyses
  6. Copy & paste output to Word document, repeatedly

alt text

alt text

Click trails are ephemeral

  • Lots of human effort for tedious & time-wasting tasks
  • Error-prone due to manual & ad hoc data handling
  • Difficult to record - hard to reconstruct a ‘click history’
  • Tiny changes in data or method require extensive reworking

Case study: Reinhart and Rogoff controversy

  • 2010: Claimed high debt-to-GDP ratios led to low GDP growth
  • Threshold to growth at a debt-to-GDP ratio of >90%
  • Substantial popular impact on autsterity politics

alt text

alt text

Excel coding error sliced several countries out of the data set…. The Economist

Case study: Seizure Medicine

2013 Seizure study retracted after authors realize data got “terribly mixed”

“The article has been retracted at the request of the authors. After carefully re-examining the data presented in the article, they identified that data of two different hospitals got terribly mixed. The published results cannot be reproduced in accordance with scientific and clinical correctness.”” Authors of Low Dose Lidocaine for Refractory Seizures in Preterm Neonates

Source

Bad spreadsheet merge kills depression paper, quick fix resurrects it

Authors informed the journal that the merge of lab results and other survey data used in the paper resulted in an error regarding the identification codes. Results of the analyses were based on the data set in which this error occurred.

Lower levels of CSF IL-6 were associated with current depression and with future depression […]” Original conclusion

Higher levels of CSF IL-6 and IL-8 were associated with current depression […]” Revised conclusion

Source

Open scripted analyses provide a solution

alt text

  • Plain text files readable for a long time
  • Improved transparency, automation, maintanability, accessibility, standardisation, modularity, portability, efficiency, communicability of process (what more could we want?)
  • Steeper learning curve

Literate statistical programming

“Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to humans what we want the computer to do.” Donald E. Knuth, Literate Programming, 1984

For example… If I say that 2 + 2 = 4, why would you believe me?

2+2
## [1] 4

The text and R code are interwoven in the output. The products are ephemeral - focus is on the methods!

Literate statistical programming

Of course 2+2 is trivial, but what if I said:

alt text

Literate programming: pros and cons

Pros

  • Text & code in one place, in logical order
  • Tables and figures automatically updated
  • Automatic test when building document

Cons

  • Text and code in one place; can be hard to read
  • Can slow down the processing of documents (use caching!)

Markdown formatting language

alt text

Markdown: lightweight document formatting syntax. Easy to write, read and publish as-is.

The human-readable part:

  • minor extensions to allow R code display and execution
  • embed images in html files (convenient for sharing)
  • equations
  • * for bullet, _ for underline

Dynamic documents in R

RMarkdown & Quarto

Engine for dynamic report generation in R

alt text

  • Narrative and code in the same file or explicitly linked
  • When data or narrative are updated, the document is automatically updated
  • Data treated as ‘read only’
  • Output treated as disposable

Quarto (by RStudio)

source

Pandoc: document converter

alt text http://kieranhealy.org/blog/archives/2014/01/23/plain-text/

A universal document converter, open source, cross-platform

  • Write code and narrative in quarto + markdown
  • use pandoc to get HTML/PDF/DOCX

Final

Abandoning the habit of secrecy in favor of process transparency and peer review was the crucial step by which alchemy became chemistry.
Raymond, E. S., 2004, The art of UNIX programming: Addison-Wesley.

Colophon

References: See Rmd file for full references and sources