Below are some practice questions on computing probabilities and constructing a bootstrap confidence interval.
Paste the code below to download a template file to answer the exercises.
download.file("https://sta101.github.io/static/practice/probability_practice_template.Rmd",
destfile = "probability_practice.rmd")
Libraries
library(tidyverse)
library(tidymodels)
library(openintro)
Data
Use the code below to load the data sets into R. This data is on
nutritional content of fast food items from several popular fast food
restaurants. The data is loaded via the openintro
package.
data(fastfood)
The FDA recommends that individuals consume fewer than 2300 mg of sodium per day. Given that you randomly select a food item off the McDonalds menu and eat the entire item, what is the probability you ingest more than 1/2 of the daily recommended value?
Let A be the event an individual consumes more than 1000 calories eating 1 item off the menu. Let B be the event an individual orders from Chick Fil-A. What can you say about events A and B?
Let A be the event that an individual ordered and consumed 1 fast food item from a fast food restaurant that contained more than 6 grams of sugar. Let B be the event an individual orders from Dairy Queen. Is event A independent of B?
You randomly sample 12 items from the Subway menu using the code below.
set.seed(4)
subwaySample = fastfood %>%
filter(restaurant == "Subway") %>%
slice_sample(n = 12)
subwaySample
## # A tibble: 12 × 17
## restaurant item calories cal_fat total_fat sat_fat trans_fat cholesterol
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Subway "Double … 220 35 5 1.5 0 100
## 2 Subway "6\" Tur… 390 110 13 3.5 0 30
## 3 Subway "6\" BBQ… 430 160 18 6 0 50
## 4 Subway "Carved … 280 110 12 4.5 0 65
## 5 Subway "Footlon… 740 200 22 10 0 90
## 6 Subway "6\" Tur… 490 210 24 9 1 50
## 7 Subway "Peppero… 790 290 32 13 0 60
## 8 Subway "6\" Tur… 280 35 4 1 0 20
## 9 Subway "6\" Ove… 320 40 5 2 0 25
## 10 Subway "Footlon… 460 40 6 2 0 0
## 11 Subway "Footlon… 640 160 18 8 0 40
## 12 Subway "6\" Ita… 410 150 16 6 0 45
## # … with 9 more variables: sodium <dbl>, total_carb <dbl>, fiber <dbl>,
## # sugar <dbl>, protein <dbl>, vit_a <dbl>, vit_c <dbl>, calcium <dbl>,
## # salad <chr>
Compute the mean cholesterol from your sample, together with a 90% confidence interval. Interpret the confidence interval.
Next compute the true mean using all the subway menu items in the
fastfood
data frame. Assuming fastfood
contains every single item on the Subway menu, does your confidence
interval capture the true mean? Use
set.seed(4)
when creating your bootstrap
distribution.