1

can someone explain to me why the following code

LogLikelihood[ MultinomialDistribution[ countstot, {dt1/ttot, dt2/ttot, dt3/ttot, dt4/ttot, dt5/ttot}], {CR1, CR2, CR3, CR4, CR5}]

does not produce a number as output, but instead this:

LogLikelihood[ MultinomialDistribution[ 156, {318/1049, 159/1049, 208/1049, 222/1049, 142/1049}], {0.00186, 0.00185, 0.00136, 0.00108, 0.00115}]

it is the first time I use LogLikelihood and MultinomialDistribution, and I have probably done something wrong, but I can't really understand what.

Thanks

J. Dowe
  • 99
  • 1
  • 5

1 Answers1

0

Taking a few clues from the documentation.

d = MultinomialDistribution[
    156, {318/1049, 159/1049, 208/1049, 222/1049, 142/1049}] // N;

These are the mean results expected from this distribution

m = Mean[d]

{47.2908, 23.6454, 30.9323, 33.0143, 21.1173}

Total[m]

156.

Taking some random values

r = RandomVariate[d]

{51, 17, 23, 41, 24}

The log-likelihood of these values (non-negative integer input for multinomial)

LogLikelihood[d, {r}]

-12.9418

Total[r]

156

Scaling up your figures and rounding so that they total 156

values  = {0.00186, 0.00185, 0.00136, 0.00108, 0.00115};
factor  = 156/Total[values];
scaled  = 0.999 factor values;
rounded = Round[scaled]

{40, 39, 29, 23, 25}

Total[rounded]

156

LogLikelihood[d, {rounded}]

-16.555

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40