On Jan 17, 9:23 am,
sadfjl...@gmail.com wrote:
>
> thanks! now i'm starting to make the connection! not to prolong this discussion, but I'm curious if you know how one would go about taking the log of the likelihood function of the compound binomial distribution in order to employ MLE.
>
> For the standard binomial distribution, the pdf is:
>
> p(y,mu) = c(n,y) * mu^y * (1-mu)^(n-y)
>
> we can maximize the log of the pdf above or, as many stats software packages, we can omit the coefficient (constant) and maximize the log of:
>
> f(p(y,mu)) = mu^y * (1-mu)^(n-y)
>
> Using the NLMIXED procedure in SAS, we could maximize the log of p(y,mu) like this:
>
> proc nlmixed data={dataset};
> eta = b0;
> p = exp(eta)/(1 + exp(eta));
> prob = comb(n,y) * (p**y) * (1-p)**(n-y);
> loglike = log(prob);
> model y ~ general(loglike);
> run;
>
> In the example above, the linear predictor (eta) just includes an intercept (b0), but if we wanted, we could add other predictors. Regardless, we could also maximize f(p(y,mu)), like:
>
> proc nlmixed data={dataset};
> eta = b0;
> p = exp(eta)/(1 + exp(eta));
> prob = (p**y) * (1-p)**(n-y);
> loglike = log(prob);
> model y ~ general(loglike);
> run;
>
> both will yield the same estimate of mu since the coefficient is simply a constant. anyway, point is that i'm not sure how to obtain the log the pdf of the compound binomial distribution.
>
> I'm not sure if you use SAS or some other program, but would you mind sharing with me equations/(code for whatever program you use) in order to take the log of the pdf of the compound binomial distribution from which one would employ MLE. Any hints/tips would be great!
You need to expand the probabilities -- by hand, or (preferably) by a
computer algebra system. I use Mathematica. Here is sample code and
the output it gives for n = 3:
CoefficientList[Product[q[j]+s*p[j],{j,n}],s] /. q[j_] -> 1-p[j]
{(1-p[1])*(1-p[2])*(1-p[3]),
p[1]*(1-p[2])*(1-p[3]) + (1-p[1])*p[2]*(1-p[3]) +
(1-p[1])*(1-p[2])*p[3],
p[1]*p[2]*(1-p[3]) + p[1]*(1-p[2])*p[3] + (1-p[1])*p[2] p[3],
p[1]*p[2]*p[3]}
Call those expressions pr[0],pr[1],pr[2],pr[3], because they are the
probabilities of y = 0,1,2,3, expressed as functions of the 3 unknowns
p[1],p[2],p[3]. Then loglike = log(pr[y]). You would also need
something like p[j] = 1/(1 + e^(-eta[j])), j = 1,2,3, possibly with
each eta[j] being a different linear function of some independent
variables. I don't know SAS, so I can't help you with the details of
communicating the model to nlmixed. Maybe someone else on the list
will help out here.