Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: MLE problem could not converge


From   jie li <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: MLE problem could not converge
Date   Mon, 10 Mar 2014 15:36:35 +0800

I am currently trying to program my own patent value elimination models
using Statas ml command, and I have got a original code that one author had
used for the same question. And my model is a bit different with his one.
So I have to make some adapt. So far, my attempts have not been very
successful. I have checked the help files of Stata, Statalist and gone
through the book of William Gould et al. on programming maximum likelihood
in Stata (they have some advice on ml check but I cannot fix the problem)
and have asked people at my department to no avail, and I have discussed
the model with teachers and they said the model setting is ok. Since I am
really a rookie in programming mle problem using stata, any advice will be
useful. My do file is shown below:
*estimate the parameter with mle
set more off
capture program drop myprog_patent
program define myprog_patent
version 12.0
args lnf mu sigma d
*d stands for the depreciation rate
tempvar lnzt lnzt1
* termiyear means the expired year of the patent
quietly gen double `lnzt'=ln(1-exp(-(`d'+0.1)))-(`d'*t)-ln(`d'+0.1)
quietly gen double `lnzt1'=ln(1-exp(-(`d'+0.1)))-(`d'*(t-1))-ln(`d'+0.1)
* this means that the patent is expired but not renewed full term
quietly replace `lnf' =
ln(normal(-(`mu'+`lnzt'-ln(nextfee))/`sigma')-normal(-(`mu'+`lnzt1'-ln(lastfee))/`sigma'))
if stat==2
* this means that the patent is not expired
quietly replace `lnf' = ln(normal((`mu'+`lnzt'-ln(nextfee))/`sigma')) if stat==4
end

* t stands for termiyear - applyear if the patent is expired or 2011 -
applyear if the patent is still renewed
ml model lf myprog_patent (mu: t = ) /sigma /d
ml check
ml search d 0 1 mu 2 10 sigma 4 20
ml maximize, difficult

And here is the results of the do file, which shows the problem is not
converged and the value of log likelihood doesn't change since the 5th
iteration is over:
. ml check

Test 1:  Calling myprog_patent to check if it computes log likelihood and
         does not alter coefficient vector...
         Passed.

Test 2:  Calling myprog_patent again to check if the same log likelihood value
         is returned...
         Passed.

------------------------------------------------------------------------------
The initial values are not feasible.  This may be because the initial values
have been chosen poorly or because there is an error in myprog_patent and it
always returns missing no matter what the parameter values.

Stata is going to search for a feasible set of initial values.
If myprog_patent is broken, this will not work and you will have to press
Break to stop the search.

Searching...
initial:       log likelihood =     -<inf>  (could not be evaluated)
searching for feasible values .+

feasible:      log likelihood = -767909.24
improving initial values ....+.....
improve:       log likelihood = -699963.77
rescaling entire vector .++++++++++++++++++++++++++++++++++++++++++++++++++.
rescale:       log likelihood = -683197.33
rescaling equations .++...+.
rescaling equations ......
rescale eq:    log likelihood = -292418.69

restarting tests...
------------------------------------------------------------------------------

Test 1:  Calling myprog_patent to check if it computes log likelihood and
         does not alter coefficient vector...
         Passed.

Test 2:  Calling myprog_patent again to check if the same log likelihood value
         is returned...
         Passed.

Test 3:  Calling myprog_patent to check if 1st derivatives are computed...
         test not relevant for type lf evaluators.

Test 4:  Calling myprog_patent again to check if the same 1st derivatives are
         returned...
         test not relevant for type lf evaluators.

Test 5:  Calling myprog_patent to check if 2nd derivatives are computed...
         test not relevant for type lf evaluators.

Test 6:  Calling myprog_patent again to check if the same 2nd derivatives are
         returned...
         test not relevant for type lf evaluators.

------------------------------------------------------------------------------
Searching for alternate values for the coefficient vector to verify that
myprog_patent returns different results when fed a different coefficient
vector:

Searching...
initial:       log likelihood =     -<inf>  (could not be evaluated)
searching for feasible values .+

feasible:      log likelihood = -936696.18
improving initial values ..+.......
improve:       log likelihood =  -586671.1

continuing with tests...
------------------------------------------------------------------------------

Test 7:  Calling myprog_patent to check log likelihood at the new values...
         Passed.

Test 8:  Calling myprog_patent requesting 1st derivatives at the new values...
         test not relevant for type lf evaluators.

Test 9:  Calling myprog_patent requesting 2nd derivatives at the new values...
         test not relevant for type lf evaluators.

------------------------------------------------------------------------------
                         myprog_patent HAS PASSED ALL TESTS
------------------------------------------------------------------------------

Test 10: Does myprog_patent produce unanticipated output?
         This is a minor issue.  Stata has been running myprog_patent with all
         output suppressed.  This time Stata will not suppress the output.  If
         you see any unanticipated output, you need to place quietly in front
         of some of the commands in myprog_patent.

-------------------------------------------------------------- begin execution
---------------------------------------------------------------- end execution

. ml search d 0 1 mu 2 10 sigma 4 20
initial:       log likelihood =  -586671.1
rescale:       log likelihood = -475204.17
rescale eq:    log likelihood = -288695.29

. ml maximize, difficult

initial:       log likelihood = -288695.29
rescale:       log likelihood = -288695.29
rescale eq:    log likelihood = -288695.29
Iteration 0:   log likelihood = -288695.29  (not concave)
Iteration 1:   log likelihood = -275824.93  (not concave)
Iteration 2:   log likelihood = -270886.91  (not concave)
Iteration 3:   log likelihood = -270752.57  (not concave)
Iteration 4:   log likelihood = -270740.94  (not concave)
Iteration 5:   log likelihood = -270740.34  (not concave)
Iteration 6:   log likelihood = -270740.34  (not concave)
Iteration 7:   log likelihood = -270740.34  (not concave)
Iteration 8:   log likelihood = -270740.34  (not concave)
Iteration 9:   log likelihood = -270740.34  (not concave)
Iteration 10:  log likelihood = -270740.34  (not concave)
Iteration 11:  log likelihood = -270740.34  (not concave)
Iteration 12:  log likelihood = -270740.34  (not concave)
Iteration 13:  log likelihood = -270740.34  (not concave)
Iteration 14:  log likelihood = -270740.34  (not concave)
Iteration 15:  log likelihood = -270740.34  (not concave)
Iteration 16:  log likelihood = -270740.34  (not concave)
Iteration 17:  log likelihood = -270740.34  (not concave)

And the results doesn't change, even I have run this for more than
1000 iteration. So I really don't know what the problem may be. And
what kind of problem it is, when the log likelihood value doesn't
change and the problem doesn't converge, too.
Could you give me some advice on how to fix this problem, does this
mean I have something wrong with my data set, or it is my function
setting which is wrong, or some other things that I just haven't come
up with.
Many regards.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index