We will define the following probabilities for a PCR test:

p - The probability that a pcr test of a **sick** person, will show us a positive result.

q - The probability that a pcr test of a **healthy** person, will show us a positive result.

s - The general percentage of patients in the population.

Let q = 10%, p = 95% and s = 20%

We want to generate data of 1000 people how came to check,

I did it in this way:

    s = 0.2

    p = 0.95

    q = 0.1

    

    true_result = c()

    test_result = c()

    

    for (i in 1:1000){

      x = runif(1,0,1)

      if (x<=s){

        true_result = append(true_result,1)

        r = runif(1,0,1)

        if (r<=p){

          test_result = append(test_result,1)

      

        }else{

          test_result = append(test_result,0)

        }

        

      }else{

        true_result = append(true_result,0)

        r = runif(1,0,1)

        if (r<=q){

          test_result = append(test_result,1)

        }

        else{

          test_result = append(test_result,0)

        }

      }

    }

Now, we want to generate 10,000 sample from the posterior.

And for that we need the prior and likelihood.

Let the priors to be:

**f_q(q) = 2q if x in [0,1] and 0 otw.**

**f_p(p)= 2(1-p) if x in [0,1] and 0 otw.**

**s ~ u(0,1)**

I calculated the joint prior in this way:

    JointPrior <- function(p,s,q){

      if(p<=0 | p>=1){

        return (0)

        

      }

      if (q<= 0 | q>=1){

        return(0)

      }

      return(s*2*q*2*(1-p))

    } 

The part where I get stuck is in the Likelihood calculation..

How can I calculate the likelihood? can someone help me with that?

in Statistics Answers by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

Without going into the programming language (which I'm not familiar with, although I get the gist of what you're doing to generate datasets using a random number generator), but, in an effort to help you derive the likelihood, by analysing the concepts you present, my thinking is illustrated by the following tree. I've started with an arbitrary sample of 10000 people from the population and then applied what I think are your statistics.

→(95%)1900 +ve
→(20% patients) 2000 "sick"→⎜
→(5%) 100 -ve
10000 people→
→(10%) 800 +ve
→→→(80%) 8000 "healthy"→⎜ 
→(90%) 7200 -ve

In 10,000 people 1900+800=2700 test +ve (27%); 7300 test -ve (73%).

So the likelihood of anyone in the population testing positive is 27%.

You can substitute algebraic quantities in place of actual figures using the table as a guide.

Not sure if this is what you meant, but I hope it's helpful.

by Top Rated User (1.1m points)

Related questions

1 answer
asked Oct 9, 2021 in Statistics Answers by Noor Level 1 User (120 points) | 247 views
1 answer
1 answer
asked Aug 11, 2014 in Statistics Answers by anonymous | 979 views
1 answer
asked Jul 13, 2013 in Statistics Answers by Leon89 Level 1 User (160 points) | 1.1k views
2 answers
1 answer
asked Mar 23, 2013 in Statistics Answers by Akilie Level 1 User (140 points) | 1.2k views
1 answer
Welcome to MathHomeworkAnswers.org, where students, teachers and math enthusiasts can ask and answer any math question. Get help and answers to any math problem including algebra, trigonometry, geometry, calculus, trigonometry, fractions, solving expression, simplifying expressions and more. Get answers to math questions. Help is always 100% free!

Most popular tags

algebra problems solving equations word problems calculating percentages math problem geometry problems calculus problems math fraction problems trigonometry problems rounding numbers simplifying expressions solve for x order of operations probability algebra pre algebra problems word problem evaluate the expression slope intercept form statistics problems factoring polynomials solving inequalities 6th grade math how to find y intercept equation of a line sequences and series algebra 2 problems logarithmic equations solving systems of equations by substitution dividing fractions greatest common factor square roots geometric shapes graphing linear equations long division solving systems of equations least to greatest dividing decimals substitution method proving trigonometric identities least common multiple factoring polynomials ratio and proportion trig identity precalculus problems standard form of an equation solving equations with fractions http: mathhomeworkanswers.org ask# function of x calculus slope of a line through 2 points algebraic expressions solving equations with variables on both sides college algebra domain of a function solving systems of equations by elimination differential equation algebra word problems distributive property solving quadratic equations perimeter of a rectangle trinomial factoring factors of a number fraction word problems slope of a line limit of a function greater than or less than geometry division fractions how to find x intercept differentiation exponents 8th grade math simplifying fractions geometry 10th grade equivalent fractions inverse function area of a triangle elimination method story problems standard deviation integral ratios simplify systems of equations containing three variables width of a rectangle percentages area of a circle circumference of a circle place value solving triangles parallel lines mathematical proofs solving linear equations 5th grade math mixed numbers to improper fractions scientific notation problems quadratic functions number of sides of a polygon length of a rectangle statistics zeros of a function prime factorization percents algebra 1 evaluating functions derivative of a function equation area of a rectangle lowest common denominator solving systems of equations by graphing integers algebra 2 diameter of a circle dividing polynomials vertex of a parabola calculus problem perpendicular lines combining like terms complex numbers geometry word problems converting fractions to decimals finding the nth term range of a function 4th grade math greatest to least ordered pairs functions radius of a circle least common denominator slope unit conversion solve for y calculators solving radical equations calculate distance between two points area word problems equation of a tangent line multiplying fractions chemistry binomial expansion place values absolute value round to the nearest tenth common denominator sets set builder notation please help me to answer this step by step significant figures simplifying radicals arithmetic sequences median age problem trigonometry graphing derivatives number patterns adding fractions radicals midpoint of a line roots of polynomials product of two consecutive numbers limits decimals compound interest please help pre-algebra problems divisibility rules graphing functions subtracting fractions angles numbers discrete mathematics volume of a cylinder simultaneous equations integration probability of an event comparing decimals factor by grouping vectors percentage expanded forms rational irrational numbers improper fractions to mixed numbers algebra1 matrices logarithms how to complete the square mean statistics problem analytic geometry geometry problem rounding decimals 5th grade math problems solving equations with variables solving quadratic equations by completing the square simplifying trigonometric equation using identities
87,446 questions
99,048 answers
2,422 comments
4,780 users