Compute the Likelihood of binomial data 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:
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.
After my research, I realized that likelihood is simply the pdf calculated with our data.
So, I want to know if I understand..
Does it make sense for likelihood to look like this:
$\\f(data|p,q,s) = \prod p^{data}(1-p)^{1-data}q^{data}(1-q)^{1-data}s\\$

Let me see if I can give you some help. I am going to change the notation a bit to make things easier for me. I like to use "p" for probability density (instead of "f").
Let $z_i = 1$ if individual $i$ has the disease and let $z_i = 0$ if the individual does not. As I understand the setup we have
\begin{equation}
p(z_i|s) = \textsf{Bernoulli}(z_i|s) = s^{z_i}\,(1-s)^{1-z_i} = \begin{cases}
1 & z_i = 1 \\
0 & z_i = 0
\end{cases} .
\end{equation}
Let $y_i = 1$ if individual $i$ tests positive for the disease and $y_i = 0$ if the individual tests negative.
Let $q_1$ denote the probability that an individual with the disease tests positive and let $q_0$ denote the probability that an individual without the disease tests positive.
Given this setup we have
\begin{align}
p(y_i|z_i=1) &= \textsf{Bernoulli}(y_i|q_1) \\
p(y_i|z_i=0) &= \textsf{Bernoulli}(y_i|q_0) 
\end{align}
which can be written compactly as
\begin{equation}
p(y_i|z_i) = \textsf{Bernoulli}(y_i|q_{z_i}) .
\end{equation}
Therefore the likelihood can be expressed as
\begin{equation}
\prod_{i=1}^n \textsf{Bernoulli}(y_i|q_{z_i}) 
\end{equation}
and the prior can be expressed as
\begin{equation}
p(s)\,p(q_0)\,p(q_1) \prod_{i=1}^n \textsf{Bernoulli}(z_i|s) .
\end{equation}
Alternatively, we can integrate each $z_i$ out in advance:
\begin{equation}
p(y_i|q_0,q_1,s) = \sum_{z_i \in \{1,0\}} p(y_i|z_i)\,p(z_i|s) = \textsf{Bernoulli}(y_i|\pi) 
\end{equation}
where
\begin{equation}
\pi = s\,q_1 + (1-s)\,q_0 .
\end{equation}
In this case we can express the likelihood as
\begin{equation}
\prod_{i=1}^n \textsf{Bernoulli}(y_i|\pi) 
\end{equation}
and the prior as
\begin{equation}
p(s)\,p(q_0)\,p(q_1) . 
\end{equation}
A bit more
Let $r = \sum_{i=1}^n y_i$ denote the number of "successes." Then
\begin{equation}
\prod_{i=1}^n \textsf{Bernoulli}(y_i|\pi) = \pi^r\,(1-\pi)^{n-r} \propto \textsf{Binomial}(r|n,\pi) .
\end{equation}
In other words, the second likelihood can just as well be expressed in terms of the binomial distribution. It makes no difference. (By contrast, the first likelihood does not have this simple correspondence, owing to the multiple "probabilities" involved in the Bernoulli distributions).
Continue to focus on the second likelihood and the definition of $\pi$. For any given value of $\pi$ there is a non-linear surface in three-dimensional space on which combinations of $s$, $q_0$, and $q_1$ satisfy the defining equation. This means that the parameters $(s,q_0,q_1)$ are "not identified." As more observations become available, the location of the surface will become less and less dependent on the prior, but the effect of the prior for where $(s,q_0,q_1)$ are located on the surface will remain. In this sense, the prior plays a more important role than is typically the case.
