Re: Maximum Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg46272] Re: Maximum Problem
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Thu, 12 Feb 2004 22:47:09 -0500 (EST)
- References: <c0fsdd$c2t$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Here is an example for a normal distribution
Needs["Statistics`NormalDistribution`"];
randData = RandomArray[NormalDistribution[5, 2], {150}];
The log likelihood function is
llf = Simplify[
Plus @@ (Log[PDF[NormalDistribution[m,s],#]]& /@ randData), {Element[{m,
s}, Reals],s>0}];
You can use NSolve
Select[
NSolve[{D[llf,m]==0,D[llf,s]==0}, {m,s}],
(s /. #) >0&]//Flatten
{m -> 4.72103, s -> 1.94323}
Or FindRoot
FindRoot[{D[llf,m]==0,
D[llf,s]==0}, {{m,Mean[randData]}, {s,StandardDeviation[randData]}}]
{m -> 4.72103, s -> 1.94323}
Bob Hanlon
In article <c0fsdd$c2t$1 at smc.vnet.net>, sabrinacasagrande at hotmail.com (sabbri)
wrote:
<< I have to maximize a function (the Likelihood function) in order to
obtain the estimators of two parameter (say B e S). So I think I need
to derive the function,(first respect to B, then respect to S) and
equalize the 2 derivatives to zero. In other words I give the command:
DSolve[{D[L[x,y],B]==0,D[L[x,y],S]==0},B,s]
but Mathematica doesn't run. Where do I make mistakes? Perhaps I need
to define the function L[x,y,B,S]??