--- 
title: "Open Forensic Science in R"
author: "Editor: Sam Tyner, Ph.D."
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output: 
  bookdown::gitbook:
    includes:
      in_header: style.css 
documentclass: book
bibliography: [bib/book.bib, bib/packages.bib, bib/glass.bib, bib/shoe.bib, bib/fingerprint.bib, bib/dna1.bib, bib/humans.bib, bib/bullets.bib, bib/casings.bib, bib/marketplaces.bib, bib/other.bib, bib/toolmarks.bib]
biblio-style: apalike
nocite: |
  @R-devtools, @R-patchwork, @R-RColorBrewer, @R-tidyr, @R-gghighlight, @R-ggpubr, @R-rgl
link-citations: yes
github-repo: sctyner/openforscir
description: "This book is for anyone looking to do forensic science analysis in a data-driven and open way."
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache=FALSE, fig.align = "center")
```


# Prologue {.unnumbered}

<img src="img/openforscir-hex.png" style="display: block; margin-left: auto; margin-right: auto; width: 20%;" />

This book is for anyone looking to do [forensic science](#def:forsci) analysis in a data-driven and open way. Whether you are a student, teacher, or scientist, this book is for you. We take the latest research, primarily from the Center for Statistics and Applications in Forensic Evidence ([CSAFE](https://forensicstats.org/)) and the National Institute of Standards and Technology ([NIST](https://www.nist.gov/)) and show you how to solve forensic science problems in [`R`](https://www.r-project.org/). The book makes some assumptions about you: 

1. **You have some experience with [`R`](#def:rstats) [@R-base].** We don't assume you are an expert by any means, but we do assume you are comfortable enough with `R` to install & library packages, load data, identify different data structures, and to follow along with the code we present in each chapter. If you need help getting started with `R`, there are lots of free resources online, and CSAFE has some resources available [here](https://csafe-isu.github.io/reu18/slides/). You can install `R` for Windows, Mac, and Linux [here](https://cloud.r-project.org/) for free. We also recommend you install [RStudio](https://www.rstudio.com/products/rstudio/download/), the wonderful free [IDE](#def:ide) (Integrated Development Environment) for `R`. If you want a deeper dive into `R`, take a walk through [*R for Data Science*](http://r4ds.had.co.nz/). If you really want to explore the depths, [*Advanced R*](https://adv-r.hadley.nz/) is an excellent resource. 
2. **You are interested in forensic science.** Hopefully that's why you're here! You may only be interested in DNA or firearms, so we've split the book up into chapters by forensic science subfield. You also don't have to be an expert in the field. We will explain the basics of the field in the introduction of each chapter. You can also download this book by clicking [here](https://github.com/sctyner/OpenForSciR/archive/master.zip) or by cloning it on [GitHub](https://github.com/sctyner/OpenForSciR) and follow along, running the code on your own computer.
3. **You care about [open source software](#def:openss).** This doesn't really affect your ability to read this book, but it's a nice quality to have. The purpose of this book is to make forensic science more accessible. Right now, most databases, algorithms, and programs that get used every day in forensic science are [proprietary](#def:proprietary), meaning that only the owners know how these systems work, how they were made, and what the [source code](#def:sourcecode) looks like. This closed approach has lead to [miscarriages of justice](https://www.propublica.org/article/thousands-of-criminal-cases-in-new-york-relied-on-disputed-dna-testing-techniques). With this free online book that relies *solely* on open-source software for analysis, we hope to demonstrate the impact open source software can have on forensic science, both in research and in practice. And in this spirit of openness, we ask that you contribute if you find an error or want to add a chapter on a topic we did not cover. You can open an issue [here](https://github.com/sctyner/OpenForSciR/issues) or fork the book's [Github repository](https://github.com/sctyner/OpenForSciR/) and submit your changes via a pull request. If you'd like to contribute, we ask that you follow our [contributor code of conduct]("https://github.com/sctyner/OpenForSciR/blob/master/CODE_OF_CONDUCT.md") and these [recommended practices](https://happygitwithr.com/fork-and-clone.html) from [Jenny Bryan](https://jennybryan.org/) and [Jim Hester](https://github.com/jimhester) of RStudio. 

<p><a href="https://zenodo.org/badge/latestdoi/99443778"><img src="https://zenodo.org/badge/99443778.svg" alt="DOI"></a></p>

This book **free** and is licensed under a [Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License](http://creativecommons.org/licenses/by-nc-nd/3.0/us/). 

<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><img alt="Creative Commons License" style="border-width:0; display: block; margin-left: auto; margin-right: auto;" src="https://i.creativecommons.org/l/by-nc-nd/3.0/us/88x31.png" /></a>


# About the Authors^[Information current as of May 20, 2019] {.unnumbered}


## Sam Tyner, Ph.D. {-}

Sam is a Postdoctoral Research Associate in the [Center for Statistics and Applications in Forensic Evidence](https://forensicstats.org/) (CSAFE) at [Iowa State University](https://www.iastate.edu/) (ISU). She earned her Ph.D. in Statistics from ISU in 2017. In 2018, she received a fellowship from [rOpenSci](https://ropensci.org/blog/2018/02/14/announcing-2018-ropensci-fellows/) to create this free book for anyone interested in open source forensic science. For more about Sam, follow her on [Twitter](https://twitter.com/sctyner) or [GitHub](https://github.com/sctyner), and visit her [website](https://sctyner.github.io/). 

## Heike Hofmann, Ph.D.  {-}

Heike is a Professor of [Statistics](https://www.stat.iastate.edu/people/heike-hofmann) at Iowa State University. She is a member of the CSAFE faculty and a core member of the [Bioinformatics and Computational Biology](https://www.bcb.iastate.edu/people/all-faculty) program at ISU. She is also a faculty member in the [Human-Computer Interaction](http://www.vrac.iastate.edu/directory/faculty/?ID=hofmann) program and is on the ISU [Data Science Curriculum Committee](https://www.datascience.iastate.edu/people-category/data-science-curriculum-committee).  Her primary research interests are data visualization, multivariate categorical data analysis, statistical computing, exploratory data analysis and interactive statistical graphics. 

## Soyoung Park, Ph.D. {-}

Soyoung Park is a Postdoctoral Research Associate at CSAFE at Iowa State University. She received her Ph.D. in Statistics from ISU in 2018. Her research interests include applied statistics, data science, forensic science, image analysis, and machine learning. Her recent research focuses on pattern matching problems in two-dimensional shoe sole impressions and optimal matching criteria for chemical matching of forensic glass fragments.

## Eric Hare, Ph.D. {-}

Eric is the Chief Data Scientist at [Omni Analytics](https://omnianalytics.io/). He earned his Ph.D. in Statistics and Computer Science from Iowa State University in 2017. For his dissertation, Eric assisted in the development of `bulletr`, the precursor to the  `x3ptools` and `bulletxtrctr` packages introduced in Chapter \@ref(#bullets), and the associated bullet matching models which are a focus of a section of this book.

## Xiao Hui Tai {-}

Xiao Hui is a Ph.D. student in the Department of Statistics and Data Science at Carnegie Mellon University. She is currently working on matching problems in forensic science. Previously she was a statistician with the Singapore government.

## Karen Kafadar, Ph.D. {-}

Karen Kafadar is Commonwealth Professor and Chair of Statistics at University of Virginia. She received her Ph.D. in Statistics from Princeton and has served on several National Academy of Science committees, including the ones that led to the reports [Weighing Bullet Lead Evidence](https://www.nap.edu/catalog/10924/forensic-analysis-weighing-bullet-lead-evidence) (2004), [Strengthening Forensic Science in the United States: A Path Forward](https://www.ncjrs.gov/pdffiles1/nij/grants/228091.pdf) (2009), [Evaluating Testing, Costs, and Benefits of Advanced Spectroscopic Portals](https://www.nap.edu/catalog/13082/evaluating-testing-costs-and-benefits-of-advanced-spectroscopic-portals-final) (2011), and [Identifying the Culprit: Assessing Eyewitness Identification](https://www.nap.edu/catalog/18891/identifying-the-culprit-assessing-eyewitness-identification) (2014). She also has served on the governing boards for the American Statistical Association (ASA), Institute of Mathematical Statistics, International Statistical Institute, National Institute of Statistical Sciences, Forensic Science Standards Board, and is the 2019 ASA President.

## Karen Pan {-}

Karen Pan is a Ph.D. student in the Department of Statistics at University of Virginia working on statistical issues in forensic science relating to fingerprints and glass evidence.

## Amanda Luby {-}

Amanda is currently finishing her Ph.D. in Statistics & Data Science at Carnegie Mellon University. Her dissertation focuses on statistical methods for understanding complex human decision-making, with applications in forensic evidence analysis. She will be an Assistant Professor of Statistics at Swarthmore College beginning August 2019. 

<!--
## Ganesh Krishnan, M.Sc. {-}

Ganesh is a Ph.D. student in Statistics & Human Computer Interaction at Iowa State University. His current work is on statistical methods for bullet and toolmark comparisons. He also has a background in Scientific Computing & Numerical Analysis.
--> 


<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><img alt="Creative Commons License" style="border-width:0; display: block; margin-left: auto; margin-right: auto;" src="https://i.creativecommons.org/l/by-nc-nd/3.0/us/88x31.png" /></a>




```{r include=FALSE}
# automatically create a bib database for R packages
knitr::write_bib(c(
  .packages(), 'bookdown', 'knitr', 'rmarkdown', "x3ptools", "bulletxtrctr", "magrittr", "dplyr", "PRROC", "DescTools", "protoclust", "EBImage", "blackboxstudyR", "rstantools", "rstan", "RColorBrewer", "tidyr", "ggplot2", "gghighlight", "ggpubr", "caret", "shoeprintr", "patchwork", "purrr", "strvalidator", "devtools", "bmp", "kableExtra", "rgl"
, "toolmaRk"), 'bib/packages.bib')
# hmmm. how to generate the glossary automatically on build.....? 
# source("code/generate-glossary.R")

```
