Chapter 2: Probability
This set of labs teaches the essential tools for writing basic simulations to estimate probabilities with the long-run frequency approach, in addition to discussing traditional algebraic approaches for solving probability questions. The programming introduced in these labs (loops and conditionals) will be used in later chapters for demonstrating concepts such as the Central Limit Theorem.
Lab Notes
1. Introduction to Probability
Introduces the basic framework for estimating probability through simulated repetitions of an experiment. The sample() command and syntax for a for loop are introduced in the context of a simple coin flipping experiment, then extended to more complex scenarios.
3. Positive Predictive Value (Bayes' Theorem)
Illustrates three common approaches for calculating the positive predictive value of a diagnostic test: contingency tables, tree diagrams, and simulation. The second part of the lab is a conceptual exploration of the relationships between prevalence, sensitivity, specificity, PPV, and NPV.
R (Base), Useful Links
The statistical software R is a widely used and stable software that is free. RStudio is a user-friendly interface for R.