Compute the Likelihood of binomial data

Amitbd14

New member
Joined
Jul 11, 2022
Messages
3
Say we have to following data:

p = 0.95 -> rate of **true positive** result of pcr test.

q = 0.1 -> rate of **false positive** result of pcr test.

s = 0.2 -> rate of **total** patients in the population

Our goal is to **estimate** the **parameters** **p**, **q** and **s** with Bayesian methods

I generated data of 1000 people who come to check and I got data with zeros and ones.

Something like that:

Code:
    really <- rbinom(1000,1,s);
    test <- rbinom(1000,1,really*p+(1-really)*q)



Now, I to compute the **likelihood** of these parameters in order to calculate the posterior later, how can I do it?

I'm really got stuck on this.


If it helps I have information about the priors:

**Prior for the parameter p:**

[math]f_q(q)=\begin{cases}2q, &\text{if } 0\leq q\leq1\\ 0, &\text{otw } \end{cases}.[/math]
**prior for the parameter q:**

[math]f_p(p)=\begin{cases}2(1-p), &\text{if } 0\leq p\leq1\\ 0, &\text{otw } \end{cases}.[/math]

**prior for the parameter s:**

[math]s\sim U(0,1)[/math]
 
Say we have to following data:

p = 0.95 -> rate of **true positive** result of pcr test.

q = 0.1 -> rate of **false positive** result of pcr test.

s = 0.2 -> rate of **total** patients in the population

Our goal is to **estimate** the **parameters** **p**, **q** and **s** with Bayesian methods

I generated data of 1000 people who come to check and I got data with zeros and ones.

Something like that:

Code:
    really <- rbinom(1000,1,s);
    test <- rbinom(1000,1,really*p+(1-really)*q)



Now, I to compute the **likelihood** of these parameters in order to calculate the posterior later, how can I do it?

I'm really got stuck on this.


If it helps I have information about the priors:

**Prior for the parameter p:**

[math]f_q(q)=\begin{cases}2q, &\text{if } 0\leq q\leq1\\ 0, &\text{otw } \end{cases}.[/math]
**prior for the parameter q:**

[math]f_p(p)=\begin{cases}2(1-p), &\text{if } 0\leq p\leq1\\ 0, &\text{otw } \end{cases}.[/math]

**prior for the parameter s:**

[math]s\sim U(0,1)[/math]
[math] \text{The Model: } f(\text{data}|p)\\ \text{The Prior: }f(p)\\ \text{The Posterior Density:} f(p|\text{data)=}\frac{f(\text{data}|p) \cdot f(p)}{\int_{-\infty}^{\infty}f(\text{data}|p)\cdot f(p)\,dp} [/math]
 
Last edited:
[math] \text{The Model: } f(\text{data}|p)\\ \text{The Prior: }f(p)\\ \text{The Posterior density:} \frac{f(\text{data}|p) \cdot f(p)}{\int_{-\infty}^{\infty}f(\text{data}|p)\cdot f(p)\,dp} [/math]

Thank you, but how to compute [math]\ f(\text{data}|p)\\ \\[/math]?

Can I use this formula? [math]\ f(\text{data}|p) = \frac{f(data\cap p)}{f(p)} \\[/math]?
 
Thank you, but how to compute [math]\ f(\text{data}|p)\\ \\[/math]?

Can I use this formula? [math]\ f(\text{data}|p) = \frac{f(data\cap p)}{f(p)} \\[/math]?
[imath]\ f(\text{data}|p)[/imath] is the distribution that you believe your data follow i.e binomial.

For example, you have the following data:
950 people were true positive and 50 people were false positive then [imath]\ f(\text{data}|p)={1000 \choose 950} p^{950}(1-p)^{50}[/imath]
 
Last edited:
[imath]\ f(\text{data}|p)[/imath] is the distribution that you believe your data follow i.e binomial.

For example, you have the following data:
950 people were true positive and 50 people were false positive then [imath]\ f(\text{data}|p)={1000 \choose 950} p^{950}(1-p)^{50}[/imath]
I think that I understand..
But I actually have
[math]\\f(data|p,q,s)\\[/math]So I need to multiply all of them? something like that?

[math]\\f(data|p,q,s) = \prod p^{data}(1-p)^{1-data}q^{data}(1-q)^{1-data}\\ [/math]
 
I think that I understand..
But I actually have
[math]\\f(data|p,q,s)\\[/math]So I need to multiply all of them? something like that?

[math]\\f(data|p,q,s) = \prod p^{data}(1-p)^{1-data}q^{data}(1-q)^{1-data}\\ [/math]
I don't follow your parameters.

If p is the probability of True Positive, then (1-p) is the probability of False Positive (this is what you call q ). So p+q mus equal 1.
Not sure I understand what s is.
 
Top