Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Tough ML Model


From   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: Tough ML Model
Date   Mon, 23 Feb 2004 08:21:22 -0600

Michael Kunz <[email protected]> offers the following -ml- method lf 
likelihood evaluator, 

        program define dbdc
                args lnf Xb
                tempvar YY YN NY NN

                quietly {
                        gen double `YY' = ln(norm(ratelow -`Xb'))
                        gen double `NN' = ln(norm(rateup- `Xb'))
                        gen double `YN' = ln(norm(rate1-`Xb')  - 1 + 
                                             norm(ratelow-`Xb'))
                        gen double `NY'=  ln(norm(rateup-`Xb') -1 + 
                                             norm(rate1 - `Xb'))
                        replace `lnf' = yy*`YY' + yn*`YN' + ny*`NY' + nn*`NN'
                }
        end

He writes, 

> I am having trouble getting the following maximum likelihood function to
> work - stata cannot find initial values that will yield a nonmissing log
> likelihood function.
>
> I've done ML check, ML search. I am about to switch methods from LF to D2 to
> see if this method will produce better results.
>
> Any suggestions, tips, existing programs out there?


Method -d2- is not going to help; better to fix this program and then, if 
there are convergence problems, consider switching to method d2.

Debugging should be easy.  Based on Stata's response, we know virtually any
value of `Xb' results in `lnf' being missing, so let's use `Xb'=0 and then,
one at a time, type the statements and look at the result.  For instance,

        . gen double YY = ln(norm(ratelow))
        . summ YY

Make sure there are no missing values.  If there are, perhaps it is because 
ratelow is missing.  Anyway, just keep going like that until you spot the 
problem.

By the way, in quoting the program above, I added a couple of close
parentheses to make the parens balance; so Michael should look at his 
code carefully.  For instance, in Michael's original email, he wrote 


                        gen double `YN' = ln(norm(rate1-`Xb')  - 1 + 
                                             norm(ratelow-`Xb')
                                                               ^
                                                               |
                                                    note missing paren

I stuck the paren where I thought it belonged.  

Concerning this statement, I have one other suggested improvement:
                                                     
                        gen double `YN' = ln(-norm(`Xb'-rate1) + 
                                             norm(ratelow-`Xb'))

That is, I substitute

          -norm(`Xb'-rate1)    for    norm(rate1-`Xb')-1

I think I did that right, yes?  F(-x) = 1-F(x).  Expressions like 
1-F(x) (or F(x)-1) are to be avoided because subtraction from 1 
introduces lots of roundoff error.  I do not think this is Michael's 
problem, but I would not be surprised if, later, once the initial-value 
problem is solved, F(x)-1 rather than -F(-x) causes him convergence 
problems.

-- Bill
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index