forked from sydneykpaul/spc_healthcare_with_R_HTML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
executable file
·140 lines (90 loc) · 4.91 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
title: "Statistical Process Control in Healthcare with R"
author: "Dwight Barry, Brendan Bettinger, Andrew Cooper, and Sydney Paul"
date: "`r format(Sys.Date(), '%B %Y')`"
site: bookdown::bookdown_site
output: bookdown::pdf_book
documentclass: book
# output:
# bookdown::pdf_book:
# pandoc_args: ["--listings"]
classoption: openany
fontsize: 12pt
geometry: margin=1in
urlcolor: blue
linkcolor: blue
github-repo: sydneykpaul/spc_healthcare
description: "Using SPC methods in healthcare can be tricky. We show you how to do it correctly, using R."
---
```{r setup, include=FALSE}
# Global options
knitr::opts_chunk$set(warning = FALSE, message = FALSE, comment = NA, highlight = TRUE, fig.height = 3.5)
# options("width" = 54)
knitr::opts_chunk$set(fig.pos = 'H')
# Load libraries
library(dplyr)
library(scales)
library(lubridate)
library(forecast)
library(ggseas)
library(qicharts2)
library(bookdown)
library(knitr)
library(ggplot2)
library(ggExtra)
library(gridExtra)
library(pander)
```
# Preface {-}
## We have a problem {#preface_problem}
Statistical process control (SPC) was a triumph of manufacturing analytics, and its success spread across a variety of industries---most improbably, into healthcare.
Healthcare is rarely compatible with the idea of an assembly line, but lean manufacturing thinking ("Lean") has taken over healthcare management around the world, and SPC methods are common tools in Lean.
Unlike in manufacturing, stability is an inherently tricky concept in healthcare, so this has led to much *misuse* of these methods. Bad methods lead to bad inferences, and bad inferences can lead to poor decisions.
This book aims to help analysts apply SPC methods more accurately in healthcare, using the statistical software R.
## Common questions {#preface_questions}
### _Who is this book for?_ {-}
This book is geared toward analysts working in the healthcare industry, who are already familiar with basic SPC methods and concepts. We do cover some basics, but we focus primarily on the areas that cause the most misunderstandings and misuse; The section [Useful References](#useful_resources) in the Additional Resources chapter provides a great place to start or continue learning about SPC.
### _What if I have never used R?_ {-}
We don't presume familiarity with R, but of course everything's easier if you've used R before.
If you haven't, here's what you need to get started:
- You can download R from [https://cran.r-project.org/](https://cran.r-project.org/).
- You can download RStudio from [https://www.rstudio.com/products/rstudio/download/](https://www.rstudio.com/products/rstudio/download/).
Some BI analysts are apprehensive about getting into R, but if you've ever written a line of SQL or created a formula in an Excel cell, this is no different in concept. Yes, the R language is full of idiosyncrasies and outright annoyances, but when you need to accomplish particular goals, it can be fairly easy!
For example, you can create a *u*-chart with only three lines of code!
<br>
\vspace{12pt}
```{r intro_example, fig.height=3, fig.width=6}
# Load the qicharts package, a simple interface to SPC charts
library(qicharts)
# Load some example data from another R package as an example
data(pcmanufact, package = "qcc")
# You can look at the data by clicking on the spreadsheet button in the
# Environment tab, or by running `View(pcmanufact)` in the console
# Create the u-chart
qicharts::qic(y = pcmanufact$x, n = pcmanufact$size, chart = "u",
main = "Easy u-chart")
```
<br>
\vspace{12pt}
Another useful feature of R: you can ask for help in R using `?`, followed by the function name, ex. `?qic`
<br>
\vspace{12pt}
Between the straightforward functions and the help documentation, you'll be coding in R in no time!
### _What do I need to start?_ {-}
First, you'll need R and RStudio, which can be downloaded from the links above.
Next, open RStudio and install the packages used in this book by copying and pasting this code into the **Console**:
```{r install_packs, eval=FALSE}
install.packages("ggplot2", "forecast", "lubridate", "fpp2", "ggExtra",
"ggseas", "gridExtra", "tidyverse", "qcc", "qicharts2",
"scales", dependencies = TRUE)
```
This book was created using R version 3.5.1 and RStudio 1.1.456. Code was tested on Mac OS 10.12.6 (aka Sierra).
## About {#preface_about}
### _Who are we?_ {-}
We are all analysts at *Seattle Children's Hospital* in Seattle, Washington, USA.
* Dwight Barry is a Principal Data Scientist in *Enterprise Analytics*. Twitter: \@healthstatsdude
* Brendan Bettinger is a Senior Analyst in *Infection Prevention*.
* Andy Cooper is a Lead Data Scientist in *Enterprise Analytics*. Twitter: \@DataSciABC
* Sydney Paul is a Data Science Intern in *Enterprise Analytics*.
### _What if I find a typo?_ {-}
You can submit pull requests for any errors or typos at https://github.com/sydneykpaul/spc_healthcare_with_r.