Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Problem with ML estimation


From   DEEPANKAR BASU <basu.15@osu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Problem with ML estimation
Date   Fri, 18 Aug 2006 12:15:24 -0400

I am not sure I understand your comment. I am trying to estimate two parameters (both constants) and not four. These constants are those contained in `theta3' and `theta5'. Since I have three distinct observations, the model should work. Or am I missing something?

I can ofcourse analytically see that the result of the estimation should give me `theta3' as +\infty (or a very large number). Would it be a problem for STATA if the result is +\infty? 

Deepankar

----- Original Message -----
From: Stas Kolenikov <skolenik@gmail.com>
Date: Friday, August 18, 2006 11:02 am
Subject: Re: st: Problem with ML estimation

> Your model is underidentified. You have three distinct observations,
> and you are trying to estimate four parameters.
> 
> On 8/17/06, DEEPANKAR BASU <basu.15@osu.edu> wrote:
> > Hi!
> >
> > I am trying to run a MLE on a small data set that I have 
> generated on my own; this is primarily to check the program. When I 
> run the program I get an error message saying "could not calculate 
> numerical derivatives; missing values encountered". Below I give 
> (in that order):
> > 1) the data generation program
> > 2) the ML program
> > 3) output of the ML program
> >
> > Any help to get the program running will be greatly appreciated.
> >
> > Thanks in advance.
> >
> > Deepankar
> >
> > =============india31A.do=================
> > clear
> > set more 1
> > version 8.2
> >
> > set obs 4000
> >
> > gen dfsize = 3
> >
> > gen dfsize1 = 0
> > replace dfsize1 = (1/8) if _n>3000
> >
> > gen p31 = (1/8)
> > replace p31 = (1/2) if _n<2001
> > replace p31 = (1/4) if (_n>2000 & _n<3001)
> >
> > gen p32 = 0
> > replace p32 = (1/8) if _n>3000
> >
> > save india31A.dta, replace
> >
> > ==================end=======================
> >
> >
> > ===============gender33A_lf.do=================
> > clear
> > set more 1
> >
> > capture program drop gender33A_lf
> > program gender33A_lf
> >    version 8.2
> >
> >    args lnf theta3 theta5
> >
> >    tempvar q1 x1 x5
> >
> >    quietly {
> >       gen double `q1' = 1/(1+exp(`theta5'))
> >
> >       gen double `x1' = 2^($ML_y1)
> >
> >       gen double `x5' = norm(-`theta3')
> >
> >    }
> >       #delimit ;
> >       quietly replace `lnf' = ln(($ML_y4*(1/`x1')*`x5') + ((1-
> `x5')*( $ML_y2*`q1' + $ML_y3*(1-`q1') )));
> >       #delimit cr
> >
> > end
> >
> >
> > use india31A.dta  /* Contains observations with N=2,3 */
> >
> >
> >
> > ml model lf gender33A_lf (dfsize p31 p32 dfsize1 = ) (), 
> tech(bhhh nr)
> >
> > ml check
> >
> > ml search
> >
> > ml max, difficult
> >
> > =====================end=============================
> >
> >
> >
> > ==================output of gender33A_lf.do=================
> > . do gender33A_lf.do
> >
> > . clear
> >
> > . set more 1
> >
> > .
> > . capture program drop gender33A_lf
> >
> > . program gender33A_lf
> >   1.    version 8.2
> >   2.
> > .    args lnf theta3 theta5
> >   3.
> > .    tempvar q1 x1 x5
> >   4.
> > .    quietly {
> >   5.       gen double `q1' = 1/(1+exp(`theta5'))
> >   6.
> > .       gen double `x1' = 2^($ML_y1)
> >   7.
> > .       gen double `x5' = norm(-`theta3')
> >   8.
> > .    }
> >   9.       #delimit ;
> > delimiter now ;
> > .       quietly replace `lnf' = ln(($ML_y4*(1/`x1')*`x5') + ((1-
> `x5')*( $ML_y2*`q1' + $ML_y3*(1-`q1') )));
> >  10.       #delimit cr
> > delimiter now cr
> > .
> > . end
> >
> > .
> > .
> > . use india31A.dta  /* Contains observations with N=2,3 */
> >
> > .
> > .
> > .
> > . ml model lf gender33A_lf (dfsize p31 p32 dfsize1 = ) (), 
> tech(bhhh nr)
> >
> > .
> > . ml check
> >
> > Test 1:  Calling gender33A_lf to check if it computes log 
> likelihood and
> >          does not alter coefficient vector...
> >          Passed.
> >
> > Test 2:  Calling gender33A_lf again to check if the same log 
> likelihood value
> >          is returned...
> >          Passed.
> >
> > Test 3:  Calling gender33A_lf to check if 1st derivatives are 
> computed...>          test not relevant for method lf.
> >
> > Test 4:  Calling gender33A_lf again to check if the same 1st 
> derivatives are
> >          returned...
> >          test not relevant for method lf.
> >
> > Test 5:  Calling gender33A_lf to check if 2nd derivatives are 
> computed...>          test not relevant for method lf.
> >
> > Test 6:  Calling gender33A_lf again to check if the same 2nd 
> derivatives are
> >          returned...
> >          test not relevant for method lf.
> >
> > ------------------------------------------------------------------
> ------------
> > Searching for alternate values for the coefficient vector to 
> verify that
> > gender33A_lf 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 = -9802.0949
> > improving initial values ..........
> > improve:       log likelihood = -9802.0949
> >
> > continuing with tests...
> > ------------------------------------------------------------------
> ------------
> >
> > Test 7:  Calling gender33A_lf to check log likelihood at the new 
> values...>          Passed.
> >
> > Test 8:  Calling gender33A_lf requesting 1st derivatives at the 
> new values...
> >          test not relevant for method lf.
> >
> > Test 9:  Calling gender33A_lf requesting 2nd derivatives at the 
> new values...
> >          test not relevant for method lf.
> >
> > ------------------------------------------------------------------
> ------------
> >                          gender33A_lf HAS PASSED ALL TESTS
> > ------------------------------------------------------------------
> ------------
> >
> > Test 10: Does gender33A_lf produce unanticipated output?
> >          This is a minor issue.  Stata has been running 
> gender33A_lf 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 gender33A_lf.
> >
> > -------------------------------------------------------------- 
> begin execution
> > ---------------------------------------------------------------- 
> end execution
> >
> > .
> > . ml search
> > initial:       log likelihood = -9802.0949
> > improve:       log likelihood = -9802.0949
> > rescale:       log likelihood = -9067.4074
> > rescale eq:    log likelihood = -4852.0303
> >
> > .
> > . ml max, difficult
> >
> > initial:       log likelihood = -4852.0303
> > rescale:       log likelihood = -4852.0303
> > rescale eq:    log likelihood = -4852.0303
> > (setting optimization to BHHH)
> > numerical derivatives are approximate
> > flat or discontinuous region encountered
> > numerical derivatives are approximate
> > flat or discontinuous region encountered
> > Iteration 0:   log likelihood = -4852.0303
> > numerical derivatives are approximate
> > flat or discontinuous region encountered
> > numerical derivatives are approximate
> > flat or discontinuous region encountered
> > Iteration 1:   log likelihood = -4852.0303  (backed up)
> > could not calculate numerical derivatives
> > missing values encountered
> > r(430);
> >
> > end of do-file
> > r(430);
> >
> > .
> > ====================end===========================
> >
> > *
> > *   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/
> >
> 
> 
> -- 
> Stas Kolenikov
> http://stas.kolenikov.name
> *
> *   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/
> 


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index