Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions manuscript/02_probability.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ Answer: No, the events can simultaneously occur and so
exclusive. To elaborate let:

{$$}
\begin{eqnarray*}
A_1 & = & \{\mbox{Person has sleep apnea}\} \\
A_2 & = & \{\mbox{Person has RLS}\}
\end{eqnarray*}
\begin{aligned}
A_1 & = \{\mbox{Person has sleep apnea}\} \\
A_2 & = \{\mbox{Person has RLS}\}
\end{aligned}
{/$$}

Then

{$$}
\begin{eqnarray*}
P(A_1 \cup A_2 ) & = & P(A_1) + P(A_2) - P(A_1 \cap
\begin{aligned}
P(A_1 \cup A_2 ) & = P(A_1) + P(A_2) - P(A_1 \cap
A_2) \\
& = & 0.13 - \mbox{Probability of having both}
\end{eqnarray*}
& = 0.13 - \mbox{Probability of having both}
\end{aligned}
{/$$}

Given the scenario, it's likely that some fraction of the population has both.
Expand Down
12 changes: 6 additions & 6 deletions manuscript/03_conditional.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ the specificity, {$$}P(- ~|~ D^c) =.985{/$$} and the prevalence
{$$}P(D) = .001{/$$}.

{$$}
\begin{eqnarray*}
P(D ~|~ +) & = &\frac{P(+~|~D)P(D)}{P(+~|~D)P(D) + P(+~|~D^c)P(D^c)}\\
& = & \frac{P(+~|~D)P(D)}{P(+~|~D)P(D) + \{1-P(-~|~D^c)\}\{1 - P(D)\}} \\
& = & \frac{.997\times .001}{.997 \times .001 + .015 \times .999}\\
& = & .062
\end{eqnarray*}
\begin{aligned}
P(D ~|~ +) & = \frac{P(+~|~D)P(D)}{P(+~|~D)P(D) + P(+~|~D^c)P(D^c)}\\
& = \frac{P(+~|~D)P(D)}{P(+~|~D)P(D) + \{1-P(-~|~D^c)\}\{1 - P(D)\}} \\
& = \frac{.997\times .001}{.997 \times .001 + .015 \times .999}\\
& = .062
\end{aligned}
{/$$}

In this population a positive test result only suggests a 6% probability that
Expand Down
110 changes: 57 additions & 53 deletions manuscript/LittleInferenceBook.Rmd
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
---
output:
html_document:
toc: true
toc_depth: 2
includes:
before_body: frontmatter.html
---


```{r book, results='asis', echo = FALSE}

# Get list of .md files from the LeanPub configuration file
chapters <- readLines(con = "Book.txt")

# Set the encoding
encoding <- "Latin1"

# Output the content of every file
invisible(
sapply(X = chapters, encoding = encoding,
FUN = function(file, encoding){
# Read in file contents
contents <- readLines(con = file, encoding = encoding)

# Replace with correct equation markers
contents <- gsub(pattern = "([{][$]{2}[}] *)|( *[{]/[$]{2}[}])",
replacement = "$$",
x = contents)

# Fix code blocks
contents <- paste(contents, collapse = "\n")
contents <- gsub(pattern = " ~ ", replacement = " \tilde ", x = contents)
contents <- gsub(pattern = paste0("\n[{](title ?= ?\"([^\"]*)\")?",
"[^~]*~~*[[:space:]]*",
"([^~]*)",
"~~*\n"),
replacement = "\n**\\2**\n\n```\n\\3\n```\n\n",
x = contents)
contents <- gsub(pattern = " \\tilde ", replacement = " ~ ", x = contents)

# Identify inline equations
contents <- gsub(pattern = "[$]{2}", replacement = "$", x = contents)
contents <- gsub(pattern = "(\n{2,})[$]([^$]*)[$]",
replacement = "\\1$$\\2$$",
x = contents)

# Output file contents
cat(contents, "\n\n", sep = "")
})
)
```

---
output:
pdf_document:
toc: true
includes:
in_header: title.tex
html_document:
toc: true
toc_depth: 2
includes:
before_body: frontmatter.html
---


```{r book, results='asis', echo = FALSE}

# Get list of .md files from the LeanPub configuration file
chapters <- readLines(con = "Book.txt")

# Set the encoding
encoding <- "Latin1"

# Output the content of every file
invisible(
sapply(X = chapters, encoding = encoding,
FUN = function(file, encoding){
# Read in file contents
contents <- readLines(con = file, encoding = encoding)

# Replace with correct equation markers
contents <- gsub(pattern = "([{][$]{2}[}] *)|( *[{]/[$]{2}[}])",
replacement = "$$",
x = contents)

# Fix code blocks
contents <- paste(contents, collapse = "\n")
contents <- gsub(pattern = " ~ ", replacement = " \tilde ", x = contents)
contents <- gsub(pattern = paste0("\n[{](title ?= ?\"([^\"]*)\")?",
"[^~]*~~*[[:space:]]*",
"([^~]*)",
"~~*\n"),
replacement = "\n**\\2**\n\n```\n\\3\n```\n\n",
x = contents)
contents <- gsub(pattern = " \\tilde ", replacement = " ~ ", x = contents)

# Identify inline equations
contents <- gsub(pattern = "[$]{2}", replacement = "$", x = contents)
contents <- gsub(pattern = "(\n{2,})[$]([^$]*)[$]",
replacement = "\\1$$\\2$$",
x = contents)

# Output file contents
cat(contents, "\n\n", sep = "")
})
)
```

8 changes: 8 additions & 0 deletions manuscript/title.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\usepackage{titling}
\setlength{\droptitle}{-1in}
\pretitle{%
\begin{center}
\LARGE
\includegraphics{images/title_page.png}\\[\bigskipamount]
}
\posttitle{\end{center}}