Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: MLE - use with Discrete Weibull mean function
Date: Wed, 11 Nov 2009 10:17:19 -0500
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <hdekhv$t3s$1@fred.mathworks.com>
References: <hd4ed6$l92$1@fred.mathworks.com>
NNTP-Posting-Host: perkinsp.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1257952639 29820 172.31.57.88 (11 Nov 2009 15:17:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Nov 2009 15:17:19 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
In-Reply-To: <hd4ed6$l92$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:584227


Erik Gadzinski wrote:
> I am having trouble with an MLE function that was passed along to me.  I am new to MATLAB and am having trouble shooting problems.  I am taking 'v' values that are randomly generated that are discrete numbers that range from 0 to a couple thousand.   In the code, "v' can have a record length of 10, 50, 100, 1000, and 10,000.   In the Llikef function I would like to take the log of the function, but I have been getting log zero when large numbers usually over 1,022 are entered into the function.  So I took the log out.  The thing I need help with is that I want my q and N (eta) values to be positive. The function sometimes outputs negative q's and eta's.  Does anybody know how to do this?  Thank you in advance!

Erik, I can't exactly tell what your code is intending to do, but you seem to be describing two problems, and perhaps confusing them (they both seem to involve logs):

> In the Llikef function I would like to take the log of the function, but I have been getting log zero

You may be referring to a problem where you want to compute the log-likelihood, and do so by first computing the liklihood,and then compute it's log, and find that the likelihood has underflowed to zero.  People usually work _directly_ with the log-likeliohood for just that reason.  So, for eaxmple, the normal log-liklihood is not computed as

   log(prod(exp(-.5*(x-mu).^2)/sigma))

but as sum(-.5*(x-mu).^2 - log(sigma))

or somesuch.

> The function sometimes outputs negative q's and eta's.

If that's where the (log-)likelihood surface has it's maximum, that's where FMINSEARCH will go.  It may also be that FMINSEARCH is just taking too big of a step at times.  In any case, reparameterize your model to maximize the log-likelihood with respect to log(q) and log(eta).  Thos new parameters are unrestricted, and when you exponetiate them to get q and eta, you are guaranteed positive values.

Hope this helps.