Statalist


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

RE: st: Could not find feasible values(was: Syntax problems with maximum likelihood (method lf))


From   "Feiveson, Alan H. (JSC-SK311)" <Alan.H.Feiveson@nasa.gov>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Could not find feasible values(was: Syntax problems with maximum likelihood (method lf))
Date   Thu, 30 Oct 2008 08:48:54 -0500

Katia - 

One way is in your the calling program (i.e. the one that has the
"model" statement), set a global macro to zero. 
global COUNT = 0

Then in your likelihood program, inert a statement such as 
global COUNT = $COUNT + 1

Then create some temporary variables that contain information about your
likelihood. Here is an example that stops after 5 calls:

The line "xxxxxx" is there to make execution stop at exactly that point,
since this will cause an error.


program define flare
version 9.0

args lnf lnK lnsig t0 

tempvar    K sig Z1 Z2 la
qui gen double `K' = exp(`lnK')
qui gen double `sig' = exp(`lnsig')                
qui gen double `Z2' = (t2 - `t0')/`sig'
qui gen double `Z1' = (t1 - `t0')/`sig'
qui gen double `la' = `K'*(norm(`Z2')-norm(`Z1'))
qui replace `lnf' = -`la'+$ML_y1*log(`la')-lngamma($ML_y1+1)

global COUNT = $COUNT+1
if $COUNT==5 {
cap drop temp*
gen tempk=`K'
gen tempz1=`Z1'
gen tempz2=`Z2'
gen tempsig=`sig'
gen templa=`la'
gen templnf=`lnf'
summ temp*
xxxxxxx
}
end


Hope this helps.

 Al F.



-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Katia
Bobulova
Sent: Thursday, October 30, 2008 8:03 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Could not find feasible values(was: Syntax problems
with maximum likelihood (method lf))

Dear Martin and Al,

thank you for your answer.

Al, could you please explain me how to put a counter? If it is not too
complicated of course.

Thanks
Katia

2008/10/30 Katia Bobulova <katia.bobulova@googlemail.com>:
> Dear all,
>
> thank you very much for your answers.
>
> I finally sorted out the problem with my program.
>
> However, when I typed ml check I received this message:
>
> The initial values are not feasible.  This may be because the initial 
> values have been chosen poorly or because there is an error in my 
> program and it always returns missing no matter what the parameter 
> values.
>
> Stata is going to use ml search to find a feasible set of initial 
> values. If myprogram is broken, this will not work and you will have 
> to press Break to make ml search stop.
> Searching...
> initial:       log likelihood =     -<inf>  (could not be evaluated)
> searching for feasible values
..................................................
> could not       find    feasible        values
> r(491);
>
> What should I do to modify myprogram so that it works? Is it possible 
> that the problem is the number of observations, i.e. they are not 
> enough?
>
> Could you please help me?I have really no idea of how to adjust my
data.
>
> Thanks
> Katia
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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