ASKurz / Doing-Bayesian-Data-Analysis-in-brms-and-the-tidyverse

The bookdown version lives here: https://bookdown.org/content/3686
GNU General Public License v3.0
147 stars 44 forks source link

Section 5.1.2 #51

Open ASKurz opened 11 months ago

ASKurz commented 11 months ago

Add in section 5.1.2, which has some important computations. Whether in table format or otherwise, do the computation in Table 5.3. Also, work through the rare-disease problem on pages 103--104. Here's that computation in code.

data.frame(p_pos_g_dis = 0.99,
           p_pos_g_nodis = 0.05) %>% 
  mutate(p_neg_g_dis = 1.0 - p_pos_g_dis,
         p_neg_g_nodis = 1.0 - p_neg_g_dis,
         p_dis = 0.001) %>% 
  mutate(p_nodis = 1.0 - p_dis) %>% 
  mutate(p_dis_g_pos = (p_pos_g_dis * p_dis) / (p_pos_g_dis * p_dis + p_pos_g_nodis * p_nodis)) %>% 
  glimpse()
Rows: 1
Columns: 7
$ p_pos_g_dis   <dbl> 0.99
$ p_pos_g_nodis <dbl> 0.05
$ p_neg_g_dis   <dbl> 0.01
$ p_neg_g_nodis <dbl> 0.99
$ p_dis         <dbl> 0.001
$ p_nodis       <dbl> 0.999
$ p_dis_g_pos   <dbl> 0.01943463

Then when you do this, reference McElreath's vampire example from Chapter 3 in either of this texts.