Re-write the code from the organ donors example from class to
For reference, here is the organ donors example:
People providing an organ for donation sometimes seek the help of a special “medical consultant”. These consultants assist the patient in all aspects of the surgery, with the goal of reducing the possibility of complications during the medical procedure and recovery. Patients might choose a consultant based in part on the historical complication rate of the consultant’s clients.
One consultant tried to attract patients by noting that the average complication rate for liver donor surgeries in the US is about 10%, but her clients have only had 3 complications in the 62 liver donor surgeries she has facilitated. She claims this is strong evidence that her work meaningfully contributes to reducing complications (and therefore she should be hired!).
and here is the code we developed in class:
sim_dist = data.frame(p_hat_sim = rep(NA, 100))
for (i in 1:100){
sim = sample(outcomes, size = 62, prob = c(0.1, 0.9), replace = TRUE)
p_hat_sim = sum(sim == "complication") / length(sim)
sim_dist$p_hat_sim[i] = p_hat_sim
}
ggplot(sim_dist, aes(x = p_hat_sim)) +
geom_dotplot()
A September 2015 Pew Research report states
The latest national poll by the Pew Research Center, conducted Sept. 22-27 among 1,502 adults, finds that 60% say that any budget deal must maintain funding for Planned Parenthood, while 32% say that any agreement must eliminate funding for the organization.
The title of this report is “Majority Says Any Budget Deal Must Include Planned Parenthood Funding”.
Do these data provide convincing (statistically significant) evidence for this title?
Answer this question using the code you developed in the previous exercises with as little modification as possible. As you are working on this exercise, you might find that you need to go back and improve your code to eliminate hard-coded values.
As usual, report a p-value and state your conclusion in context of the data and the research question. Once again, use inline R code for incorporating the p-value in the text.
one_prop_test
In class on Thursday we will discuss a generic implementation of a function for performing hypothesis tests of single proportions. Evaluate both Organ Donor and Planned Parenthood data using the one_prop_test
function and compare the results to what you obtained in Tasks 1 and 2.
Hint - You will need to create and properly format the data in a way that one_prop_test
expects, specifically as a vector of character strings. You can use the rep
and c
functions to create these vectors so that they match the described data.
There should be a AppEx_10_24_2016.Rmd
file in your Teams AppEx repo, add you answers and writeup to that file and commit and push your changes to github.
Tuesday, Nov 1st by 5 pm