BetaBinomialDistribution is parametrized by three parameters [α, β, n], so it appears that all manipulations are limited to having a single value of n. Is it possible to re-define the distribution so it would take multiple different trial size as part of the data along with observation counts, and allow to use FindDistributionParameters on it ? Also - how can I compute the likelihood for a sample with variable number of trials, so the data is, for example:

1 success out of 2 trials
17 successes out of 30 trials

d = {1, 17}; 
n = {2, 30}; 
  • $\begingroup$ Is this a question about data, or a question about the Beta Binomial distribution? Is not the point of the BetaBinomial that the success probability $p$, instead of being fixed, is itself a random variable with a Beta(a,b) distribution. $\endgroup$ – wolfies Jan 11 '17 at 18:08
  • $\begingroup$ I don't think this should migrated. I think it's about BetaBinomialDistribution $\endgroup$ – m_goldberg Jan 11 '17 at 22:41
  • $\begingroup$ This is about using BetaBinomialDistribution functionality within Mathematica. $\endgroup$ – Leon Jan 12 '17 at 2:20
  • 1
    $\begingroup$ I've voted to close because the question is not specific enough. My guess is that the OP has two different samples from beta binomial random variables with common parameters $\alpha$ and $\beta$ and known sample sizes, 1 and 17. The objective is to use the two different samples to obtain maximum likelihood estimates of $\alpha$ and $\beta$. But it is likely that the maximum likelihood estimators won't be very good given that one of the sample sizes is 1. Alternatively, the OP might want the distribution of the sum of the two random variables. In short, more specifics are needed. $\endgroup$ – JimB Jan 12 '17 at 3:52
  • 1
    $\begingroup$ I understand that you're new to Mathematica and to this forum. What's needed (usually) is to show your effort to write Mathematica code and that you have looked at the online manual. The functions Likelihood and LogLikelihood are very explicit. But when questions sound like "Supply the code to do the following...", you at best won't get the depth of response or level of interest that would be helpful. $\endgroup$ – JimB Jan 15 '17 at 0:55

If you want maximum likelihood estimates based on multiple samples from beta binomial distributions with the same parameters $\alpha$ and $\beta$ but the fixed and known sample sizes vary, then here is an approach to do so:

(* Sample sizes *)
n = {2, 30, 20, 21, 56, 27};

(* Random samples with α=3 and β=2 *)
d = Flatten[
   Table[RandomVariate[BetaBinomialDistribution[3, 2, n[[i]]], 1], {i, Length[n]}]];

(* Log of likelihood *)
logL = Sum[LogLikelihood[BetaBinomialDistribution[α, β, n[[i]]], {d[[i]]}], {i, Length[n]}];

(* Find maximum likelihood estimates *)
sol = FindMaximum[{logL, α > 0 && β > 0}, {{α, 3}, {β, 2}}]
(* {-16.74694495424507,{α -> 3.5777414111204497,β -> 2.871340409996666}} *)


It turns out that if one creates a multivariate random variable using TransformedDistribution, one can then use FindDistributionParameters directly (at least for this combination of distributions):

(*Sample sizes*)
n = {2, 30, 20, 21, 56, 27};

dist = TransformedDistribution[
  Table[ToExpression["x" <> ToString[i]], {i, Length[n]}],
  Table[ToExpression["x" <> ToString[i]] \[Distributed] 
    BetaBinomialDistribution[a, b, n[[i]]], {i, Length[n]}]]

(*Random samples with α=3 and β=2*)
x = Flatten[Table[RandomVariate[BetaBinomialDistribution[3, 2, n[[i]]], 1], {i, Length[n]}]];

FindDistributionParameters[{x}, dist]
(* {a -> 3.5777390778400413`,b -> 2.8713390386213904`} *)
  • $\begingroup$ Thank you, you must have seen my second question (moved to StackExchange for some reason) and in addition to answering this one also almost answered the second one. The first one was about Mathematica syntax to use in order to work with variable sample sizes. I see how to do that now. The second was about getting confidence intervals on parameter estimates (instead of a point estimate). Also would be most helpful to parametrize not with "shape" parameters alpha and beta but with the proportion and deviance. $\endgroup$ – Leon Jan 12 '17 at 21:32
  • $\begingroup$ For both questions I highly recommend re-writing your questions in terms of Mathematica code and explicit objectives. As you've hopefully noticed, the above question is on hold until you make such changes. You can't just say "Is there a way to work with a variable number of trials?" With a more explicit question you'll get more and better help. If you do so, I'll supply an explicit answer to your other question on confidence intervals. $\endgroup$ – JimB Jan 12 '17 at 22:09
  • $\begingroup$ And by "re-writing" I mean "editing the existing question". $\endgroup$ – JimB Jan 12 '17 at 23:26
  • $\begingroup$ I am happy to try, except being new to this format I am not sure what is expected of me. In fact my question here (not the other one) was about the existence of appropriate syntax. Thank you very much for your help. Also - I do not understand how do I re-gain access to the other question and ability to edit it since it is moved to another forum. $\endgroup$ – Leon Jan 15 '17 at 0:34
  • $\begingroup$ Your other question is at stats.stackexchange.com/questions/255754/…. Hit the 'edit' button just at the bottom left of your question and add in the necessary details (such as what $\theta$ is exactly and that you intend to run the analyses in Mathematica). $\endgroup$ – JimB Jan 15 '17 at 3:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.