What is the margin of error for the estimate of the proportion of non-helmet wearers that have texted while driving each day for the past 30 days based on this survey?
se <- boot_helmet |>summarise(se =sd(stat)) |>pull()se
[1] 0.003217189
me <-1.96*seme
[1] 0.00630569
Exercise 4.
Using the infer package, calculate confidence intervals for two other categorical variables (you’ll need to decide which level to call “success”, and report the associated margins of error.
what proportion of the population is Asian and wears a helmet.
unique(yrbss$race)
[1] "Black or African American"
[2] "Native Hawaiian or Other Pacific Islander"
[3] NA
[4] "American Indian or Alaska Native"
[5] "White"
[6] "Asian"
se <- boot_asian |>summarise(se =sd(stat)) |>pull()se
[1] 0.01450958
me <-1.96*seme
[1] 0.02843878
Interpret the interval in context of the data.
answer: Based on this survey, with a standard error of 0.014 and a marginal error of 0.028 we are 95% sure that the proportion of people who are Asian and always wear a helmet is between 0.043 and 0.097.
Exercise 5.
Describe the relationship between p and me. Include the margin of error vs. population proportion plot you constructed in your answer. For a given sample size, for which value of p is margin of error maximized?
n <-1000p <-seq(from =0, to =1, by =0.01)me <-2*sqrt(p * (1- p)/n)
dd <-data.frame(p = p, me = me)ggplot(data = dd, aes(x = p, y = me)) +geom_line() +labs(x ="Population Proportion", y ="Margin of Error")
answer: Me decreses towards 0 as P goes to its highest and lowest values. It reaches it’s maximum when P is 0.50