Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group ›...

30
Reproducible Research Liz Bageant [email protected] Cornell University and Collabora*ve

Transcript of Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group ›...

Page 1: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ReproducibleResearch

[email protected]

andCollabora*ve

Page 2: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Outline

1.  ScienAficmethodandresearchfailures2.  Definingreproducibleresearch3.  Strategiesforreproducibility

Page 3: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ObservaAon AskQuesAon

BackgroundResearch

FormHypothesis

DesignExperiment/

Study

CarryOutExperiment/

Study

Data

Analysis

Conclusions

ReportResults

Results

ThescienAficmethod

Sche

maA

ccourtesyofE

rikaMud

rak

1.ScienAficmethodandresearchfailure

Page 4: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ConAnuumofresearchfailure

Disorganiza*on Egregiousbehavior

FailureofintegrityFailureofprocess

Deliberatemanipula.onofdatatogetresults-P-hacking-”Fishingexpedi.ons”

1.ScienAficmethodandresearchfailure

Page 5: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ObservaAon AskQuesAon

BackgroundResearch

FormHypothesis

DesignExperiment/

Study

CarryOutExperiment/

Study

Data

Analysis

Conclusions

ReportResults

Results

P-hacking/fishingexpediAon

P<0.05

1.ScienAficmethodandresearchfailure

Page 6: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ConAnuumofresearchfailure

Disorganiza*on Egregiousbehavior

FailureofintegrityFailureofprocess

Deliberatemanipula.onofdatatogetresults-P-hacking-”Fishingexpedi.ons”

HARK-ing

1.ScienAficmethodandresearchfailure

Page 7: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

P-hackyourwaytoscienAficglory

hVps://projects.fivethirtyeight.com/p-hacking/

1.ScienAficmethodandresearchfailure

Page 8: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ObservaAon AskQuesAon

BackgroundResearch

FormHypothesis

DesignExperiment/

Study

CarryOutExperiment/

Study

Data

Analysis

Conclusions

ReportResults

Results

HypothesizingAYerResultsareKnown(HARK-ing)

1.ScienAficmethodandresearchfailure

Page 9: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

IsHARK-ingeverokay?

Exploratory Confirmatory

ResearchGoals

•  Exploratoryresearch=hypothesisgeneraAon•  Confirmatoryresearch=hypothesistesAng

1.ScienAficmethodandresearchfailure

Page 10: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ConAnuumofresearchfailure

Disorganiza*on Egregiousbehavior

FailureofintegrityFailureofprocess

Deliberatemanipula.onofdatatogetresults-P-hacking-”Fishingexpedi.ons”

HARK-ing“Gardenofforkingpaths”

1.ScienAficmethodandresearchfailure

Page 11: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Data

Analysis

ReportResults

Results

Thegardenofforkingpaths(GelmanandLoken,2013)

Thisobserva.onseemsfunny—shouldIthrowitout?

Imputemissingdata?

OtherstudiescontrolforX,somaybeIshouldaddthatin?

ShouldIlogtransformthis?

Logit,probitorlinearprobabilitymodel?

CanwereallyassumethatXisexogenous?Everyoneelsedoes.

Itriedthisthingbutitwasn’tsignificant,doIreportit?Thisdistribu.onlooksfunny—howcanIfixit?

Thoseresultsdidn’tmakesense,shouldIreportthemanyway?Towinsorizeornottowinsorize….

Myinterac.onisn’tsignificant…shouldItakeitout?

Thisobserva.onseemsfunny—shouldIthrowitout?

Imputemissingdata?OtherstudiescontrolforX,somaybeIshouldaddthatin?

ShouldIlogtransformthis?

Logit,probitorlinearprobabilitymodel?

CanwereallyassumethatXisexogenous?Everyoneelsedoes.

Itriedthisthingbutitwasn’tsignificant,doIreportit?

Thisdistribu.onlooksfunny—howcanIfixit?

Thoseresultsdidn’tmakesense,shouldIreportthemanyway?

Towinsorizeornottowinsorize….Myinterac.onisn’tsignificant…shouldItakeitout?

Imputemissingdata?

1.ScienAficmethodandresearchfailure

Page 12: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ConAnuumofresearchfailure

Disorganiza*on Egregiousbehavior

FailureofintegrityFailureofprocess

Deliberatemanipula.onofdatatogetresults-P-hacking-”Fishingexpedi.ons”

HARK-ing“Gardenofforkingpaths”

CodingerrorsPoordocumenta.on

1.ScienAficmethodandresearchfailure

Page 13: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Toavoidtheperilsofthegarden,HARK-ing,P-hacking,andsillymistakes…

•  Integrity!-->Behonestwithyourself.•  Transparency!-->Behonestwithyourreaders.•  Doyoufeelgoodenoughaboutyourdecision-makingprocessestowritethemdownforalltosee?

Reproducibleresearch!

1.ScienAficmethodandresearchfailure

Page 14: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Replicabilityvsreproducibility•  Replicability

–  EssenAaltothescienAficmethod–  repeaAngastudyfromscratchusingnewdata,analystandcode–  ifagivenrelaAonshipbetweenXandYistrue,itshouldshowupin

mulAplestudies

2.DefiningReproducibility

Page 15: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ObservaAon AskQuesAon

BackgroundResearch

FormHypothesis

DesignExperiment/

Study

CarryOutExperiment/

Study

Data

Analysis

Conclusions

ReportResults

Results

Replicability2.DefiningReproducibility

Page 16: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Replicabilityvsreproducibility•  Reproducibility

–  GefngtheexactsameresultasanexisAngstudyusingnewanalyst,butsamedataandcode

–  RecentlytractableduetocompuAngandsoYwareadvances

2.DefiningReproducibility

Page 17: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ObservaAon AskQuesAon

BackgroundResearch

FormHypothesis

DesignExperiment/

Study

CarryOutExperiment/

Study

Data

Analysis

Conclusions

ReportResults

Results

Reproducibility2.DefiningReproducibility

Page 18: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Reproducibility

•  FacilitatetransparencybycommunicaAngprocedureseasily

•  IdenAfyinadvertenterrors•  Avoidembarrassment•  FacilitatecollaboraAon•  SaveAme•  GreaterpotenAalforextensionofwork-->higherimpactoverAme

2.DefiningReproducibility

Page 19: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Thepublic/theintegrityofscience

Researchersinyourfield

Reviewers

Colleagues/Coauthors

Youin6months

Younextweek

You!

Whoareyouaccountableto?2.DefiningReproducibility

Page 20: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Whatareweaimingfor?•  SufficientdocumentaAontobringanunfamiliaruserupto

speed–  Codebook–  Readmefile–  Variableandvaluelabelsinanalysisdataset–  EffecAvecommentsincode

•  Asingleclickexecutesyourprojectfromstarttofinish.–  Downloading–  Reformafng–  CleaningandvariableconstrucAon–  Analysis–  Outputtables,graphs,figures–  Reproduciblereport

2.DefiningReproducibility

Page 21: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Howdowegetthere?

•  Separatethephasesofdatawork•  SystemaAcfileandnamingstructures•  EffecAveandorganizedscripAng•  Reproduciblereports

2.DefiningReproducibility

Page 22: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Separatephasesofdatawork

1.  Dataconversion/cleaning/variableconstrucAon

2.  Analysis3.  ReportgeneraAon

3.StrategiesforReproducibility

Page 23: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

NamingconvenAons•  AgreewithyourcollaboratorsonnamingconvenAons.•  Humanreadable

–  Short,usefulnames–  InformaAononcontent

•  Machinereadable–  Avoidspecialcharacters,spaces,etc

•  CamelCase,ALLCAPS,lowercase,alloneword,underscore_between–  Consistentnamingtofacilitatesearching

•  Defaultordering–  DateformatYYYYMMDD–  Othernumbers—addleadingzeros

•  Nevercallsomething“final”.Itprobablyisn’t.

3.StrategiesforReproducibility

Page 24: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

SystemaAcfilestructure

•  Mustbecommontoallusers!•  ChooseafilestructureandsAcktoit.•  Makeskeletonoffolderswhenyoustartaproject.

3.StrategiesforReproducibility

Page 25: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

•  /dta/original/stataraw/clean/analysis

•  /documenta*on/metadata/reports

•  /do/cleaning/analysismaster.do

•  /output/figures/tables/oldoutput

•  /wri*ng/paper1/paper2/notes/olddraYs

•  /temp

Variable-ormodule-specificcleanfiles

Copyofread-onlyoriginalfilesexactlyasobtained.DataaYerconversiontoformatofchoice

Dataset(s)youwilluseforanalysis

Any/allcodebooksormetadatarelatedtodataCollecAonofdocumentswherethedatawasused,cited,described

Cleaning,merging,reshaping,variableconstrucAonscriptsAnalysisscripts

ScriptthatsetsuprelaAvefilepathsandcallsallscripts

SeparatefoldersifmulAplepapersusingthesamedata

OpAonalasneededKeepolderversionsofpaper,butgetthemoutoftheway

Keepforreference,ifyouchoose.

Subfoldersdependontypeofproject

GetridofcluVerasyoumakeit

Page 26: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ScripAngAps•  Data+Script=ReproducibleOutput•  Masterscript:Runsotherscriptsincorrectorder•  ModularscripAngvs.onebigfile

–  Separatetypesofprocesses(cleaning,analysis)–  AvoidrepeaAngblocksofcode:Separateprogramforrepeatedprocesses

•  Notes/comments.–  Consistentheaders–  Usefulcomments,notexpressionsoffeeling

•  Clarity>efficiency?Consideryourcollaborators.•  Re-runscriptfromthebeginningregularly.Itmustrun!

3.StrategiesforReproducibility

Page 27: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

ReproducibleReports

•  Integratecodeintotheproseofyourreport•  Singlefilethatexecutesallstepsofdataprocessandoutputsafinalpaper

•  Knowexactlywhatdatawasusedforanalysis,whatcodemadewhichfigure,etc.

•  Disadvantages—learningcurve,iniAalinvestment.

•  AlternaAvemethod:Copyandpaste.

3.StrategiesforReproducibility

Page 28: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

Avoidresearchfailuresbyimplemen*ngreproducibleresearchtechniquestoimprove

organiza*onandtransparency

1.  Separatephasesofresearch2.  SystemaAcfilenamingandstructure3.  EffecAveandorganizedscripAng4.  Reproduciblereports

•  PrioriAzeelementsthatareaVainableforyou.

Yourfutureselfthanksyou!

Page 29: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and

AddiAonalresources

•  P-hackyourwaytoscienAficglory!hVps://projects.fivethirtyeight.com/p-hacking/

•  GelmanandLoken(2013)GardenofForkingPaths.hVp://www.stat.columbia.edu/~gelman/research/unpublished/p_hacking.pdf

Page 30: Reproducible Research - Cornell Universitybarrett.dyson.cornell.edu › research › group › Reproducibility... · 2019-06-08 · Reproducible research! 1. ScienAfic method and