Need to write r code and proof

Assignment Help Humanities
Reference no: EM131058149

Problem 4: Antimicrobial resistance (AMR) is becoming a significant problem due to overuse of antimicrobial drugs. The level of AMR can be estimated by testing isolates obtained from samples (say from retail chicken). Suppose that Y isolates test positive for AMR in N samples. A Bayesian model for the population prevalence of resistance, P, is Y |P ∼ B(N, P), combined with a uniform prior distribution on P. This implies a beta posterior distribution for P. (See the notes from Lecture 14.) Suppose, however, that the test has known sensitivity and specificity values,

πse = P(positive test result|resistant)

and

πsp = P(negative test result|not resistant).

A perfect test would have πse = πsp = 1 but this is rarely the case in practice. Let TP denote a "true positive" test result event; that is, a resistant isolate that tests positive. Let NT P denote the number of TP events in the sample.

Let FP denote a "false positive" test result, a non-resistant isolate that tests positive, and let NF P denote the number of such events. Similarly, let TN and FN denote "true negative" and "false negative" test results, and let NT N and NF N denote the number of times these events occur in the sample. Note that Y = NT P + NF P and N - Y = NT N + NF N .

4a: (2 points) Determine the conditional probabilities of the events TP, FP, TN an FN given P.

4b: (4 points) What is the distribution of NT P given P and Y ? What is the distribution of NT N given P and Y ? Hence, what is the distribution of (NT P , NT N ) given P and Y ?

4c: (4 points) What is the distribution of P given (NT P , NT N ) and Y ? Note that NT P +NF N is the true number of resistance isolates in the sample.

4d:  Based on your answers to problems to 4a-c write an R function to generate values from the posterior distribution of P given Y using a Gibbs sampler.

Mygibbs=function(N,Y,sens,spec,L)
{
6

# L=chain length

your code
return(Pchain)
}

Submit your function on CMS as Mygibbs.r.

4e: Use your function to estimate the posterior distribution of P based on Y = 30 positive test results out of N = 100 if πse = 0.9 and πsp = 0.8. Report estimates of the mean, median, and 2.5 and 97.5 percentiles of the posterior distribution.

Reference no: EM131058149

Questions Cloud

Design a database for an airline : Your design should include an E-R diagram, a set of relational schemas, and a list of constraints, including primary-key and foreign-key constraints.
How does seniority play a role in how overtime is scheduled : If an overtime list is created, how should it be managed since there are certain workers qualified for some tasks but not others? Should there be several task specific lists created, or an overall shop list? If a listed is created for overtime, ma..
Mean length of jail time : Suppose that it is somehow known that the population standard deviation is 1.5. If you were conducting a hypothesis test to determine if the mean length of jail time has increased, what would the null and alternative hypotheses be? The distributio..
Find all instructors earning the highest salary : Find the IDs of all students who were taught by an instructor named Einstein; make sure there are no duplicates in the result.
Need to write r code and proof : Problem 4: Antimicrobial resistance (AMR) is becoming a significant problem due to overuse of antimicrobial drugs. The level of AMR can be estimated by testing isolates obtained from samples (say from retail chicken). Suppose that Y isolates test ..
Probability of observing a sample mean : Find the probability of observing a sample mean of 0.985 liters or less in a sample of 70 bottles, if the beverage dispensing unit functions properly.
Total current liabilities for the same period : Total current assets for a firm at the end of 2014 were $2,550,100. Total current liabilities for the same period were $1,980,312. Net working capital at the end of 2014 was:
Which of the constraints can the system check automatically : Which of these constraints can the system check automatically? Explain your answer.
What was total real return on investment : You bought one of Great White Shark Repellant Co.’s 11 percent coupon bonds one year ago for $810. These bonds make annual payments and mature 7 years from now. Suppose you decide to sell your bonds today, when the required return on the bonds is 13 ..

Reviews

Write a Review

Humanities Questions & Answers

  Consider the cmos amplifier

D 8.44 Consider the CMOS amplifier of Fig. 8.16(a) when fabricated with a process for which k1n = 4k1p = 400 μA/V2, / Vt / 0.5 V, and /VA /=5 V. Find IREF and (W/L)1 to obtain a voltage gain of -40 V/V and an output resistance of 100 kΩ. Recall th..

  Challenges facing newly independent countries

What appear to be the 3-4 major challenges facing newly independent countries once freed from European control? For best results frame your answer in at least two full paragraphs.

  Continue working on the criminal justice program proposal

continue working on the criminal justice program proposal for the problem.write a 1750- to 2100-word proposal that

  Provides coherent and well-designed instructions

Writing assignment #2 will be an instruction manual. For this assignment, you will write a document that provides coherent and well-designed instructions on completing a task.

  Discuss russian organized crime in the ussr the russian

Discuss Russian organized crime in the USSR, the Russian Republic and the US with reference to its structure and activities.

  Some enlightenment thinkers saw the cultures captain cook

some enlightenment thinkers saw the cultures captain cook encountered as noble savages free from the impositions of

  Common-sized financial statements

What common-sized financial statements tell you that you couldn't learn from the financial statements themselves? Be specific.

  Fundamentals of oral communication

what is the number one most important thing you learned from this class? Explain your answer. Why is it the most important? How will you use it in the future?

  Experiences with persuasive writingdescribe experiences you

experiences with persuasive writingdescribe experiences you have had with persuasive writing writing to

  Transnational labour, slavery and revolt

Transnational Labour, Slavery, and Revolt, Workers Organizations During the Time of the First and Second International

  You will turn in a final version of the 1200-1500 word

you will turn in a final version of the 1200-1500 word critical essay about the three works addressing the following

  How is the external environment analyzed

How is the external environment analyzed? External environmental analysis is the process of identifying and monitoring the environment in which a client exists and the opportunities and threats that are present.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd