Question

Need R code for b Thanks ! In this first question, we explore the utility of...

Need R code for b Thanks !

In this first question, we explore the utility of Bayes' theorem by examining the effectiveness of a recent egg recall. Over a 3-month period in 2010, 550 million eggs were recalled due to possible salmonella contamination out of a total 17.5 billion eggs produced in the US during that period. A risk assessment performed by the USDA several years back found that the baseline probability of salmonella contamination in eggs is about 1/100,000. Let's take this to be the probability of salmonella contamination given that an egg was not recalled. Finally, it's difficult to find definitive numbers, but let's assume that the probability that an egg was contaminated with salmonella given that it was recalled was 1/1000 1.

a.  An important question is whether the recall was effective at addressing the problem of contamination. What is the probability that an egg was recalled given that it was contaminated with salmonella? Use Bayes' theorem to calculate this value with the help of your favorite calculator Does it appear that the recall was effective? Write a few sentences interpreting the probability value that you calculated

b. Use R to simulate the answer to this question. That is, first generate an event B (an egg is recalled), for which the unconditional probability of "success" matches above. Then, generate an event A (an egg is contaminated), for which the probability of "success" varies depending on whether B was successful or not. Finally, select only trials where A is successful and compute how frequently B is successful. Run this simulation for 10,000,000 eggs and report the result. Does your simulated answer match the result of (a)? If the numbers do not match precisely, briefly describe why they differ. (NB: You may find a different approach that works, but I have found that this i easiest to accomplish with two separate for loops- one to generate the events, and one to pick out the ones that match your criteria. Also, it will likely take some time for your program to run with 10,000,000 eggs. You'll probably want to start with a smaller number [like 100,000] until you get your function up and running.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Need R code for b Thanks ! In this first question, we explore the utility of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 6. [R Programming| In order to complete this question, we will need to use a fundamen-...

    6. [R Programming| In order to complete this question, we will need to use a fundamen- tal theorem in probabilty theory known as the (Weak) Law of Large Numbers (WLLN) The WLLN will be covered in greater detail in Chapter 8, however we will use this key result throughout the course to approximate probabilities that are otherwise difficult to calculate theoretically. A simplified version of the theorem goes as follows. Assume we are interested in com- puting the probability of...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT