# Help me understand how to apply a beta-binomial model in order to estimate a parameter when there are several Bernoulli trials?

So, I have been presented with this question: A sample of 100 people were asked how many days they drove their car during the last week (inc. the weekend). The resulting frequency of response is shown below:

Days, frequency

0, 1

1, 5

2, 3

3, 15

4, 20

5, 25

6, 31

7, 0

I need to use a beta-binomial model in order to estimate the average number of 'car driven' days a week for a uniform prior. There are a total of 7 Bernoulli trials, each with success probability p.

I'm incredibly confused at what the outcome will be. I know that for a uniform prior that alpha = 1, and beta = 1, but I don't know how to apply this all to get the average?

Thank you.

If you have the prior distribution $$\mathsf{Beta}(\alpha_0, \beta_0)$$ for Success probability $$\theta$$ and binomial likelihood $$\theta^x(1-\theta)^{n-x},$$ corresponding to $$x$$ Successes in $$n$$ Bernoulli trials, then by Bayes' Theorem you have the posterior distribution is $$\mathsf{Beta}(\alpha_n = \alpha_0 + x,\; \beta_n = \beta_0 + n - x),$$ which has posterior mean $$E(\theta) = \frac{\alpha_n}{\alpha_n+\beta_n}.$$

According to Bayes' Theorem, POSTERIOR = PRIOR $$\times$$ LIKELIHOOD: $$h(\theta|x) = f(\theta) \times g(x|\theta)\propto\theta^{\alpha_n+1}(1-\theta)^{\beta_n+1}$$ $$\propto \theta^{\alpha_0+1}(1-\theta)^{\beta_0+1} \times \theta^x(1-\theta)^{n-x},$$ where $$\propto$$ (read as "proportional to") acknowledges that we have omitted normalization constants to write 'kernels' of densities instead of densities. We recognize $$\theta^{\alpha_n+1}(1-\theta)^{\beta_n+1}$$ as the kernel of $$\mathsf{Beta}(\alpha_n,\beta_n).$$

If I understand your data correctly, you observed $$x = 447$$ days of use out of $$n = 700.$$ Also, it seems you are to assume that car use is equally likely on all days, that days of use are independent within any one subject, and that subjects use cars independently of one another. These assumptions are required if we are to have 700 independent trials, each with the same Success probability $$\theta.$$

d = 0:7; f=c(1,5,3,15,20,25,31,0);  sum(d*f)
 447


So if you begin with a flat prior $$\mathsf{Unif}(0,1)\equiv\mathsf{Beta}(1,1),$$ then your posterior distribution is $$\mathsf{Beta}(448,554).$$ Your posterior mean is $$E(\theta) = \frac{448}{1002}$$ and a 95% Bayesian posterior probability interval ('credible' interval) for $$\theta$$ is $$(0.416, 0.478).$$

qbeta(c(.025, .975), 448, 554)
 0.4164427 0.4779689


Note: For various theoretical and technical reasons, some Bayesian statisticians prefer to use the Jeffries prior $$\mathsf{Beta}(.5,.5)$$ as a non-informative prior distribution, instead of the uniform prior $$\mathsf{Beta}(1,1).$$

• there are only 7 trials here, each with their own success probability. i.e. trial 1 has a success probability of 5/100, trial 2 has a success probability of 3/100. From what you have done, I think I can see that we posterior distribution after applying the beta-binomial model with flat prior, and this posterior distribution is what we use to estimate the mean? It's extra confusing with all the independent trials too! – dustedcat Aug 1 at 5:41
• I think either your Question is what you want answered or your Comment is describing something entirely different. Please try to be clear about the data and the assumptions, then maybe someone can give you an answer. – BruceET Aug 1 at 18:13
• what I'm telling you is what I've been told by my teacher. Where did you get x = 447? – dustedcat Aug 1 at 20:35
• sum(d*f) gives 447, as shown. – BruceET Aug 1 at 21:02
• yes thank you, I have just worked through what you did after a good night's sleep and it's very helpful!! The posterior mean E(theta) is this simply the expected proportion of successes value? I'm just confused as to how this translates into the "average number of 'car driven' days"? – dustedcat Aug 1 at 21:05