Hi Marcelo
The $ML_y1 - $ML_y5 macros refer to the dependent variables in your
equations. Since you haven't specified any dependent variables they
contain nothing which is why you get the error message. Try something
like:
ml model lf itrader (ML_y1 = ) (ML_y2 = ) (ML_y3 = ) (ML_y4 ML_y5 = )
note that the dependent variables need not be called ML_y1-ML_y5, they
can be called anything you like. -ml- will automatically create the
$ML_y1 - $ML_y5 macros referring to the dependent variables.
Hope this helps.
Arne
On 22/08/06, Marcelo Cadena <[email protected]> wrote:
I am trying to maximize the following likelihood function
implemented in my do-file below. In my opinion the
structure of the program corresponds to the one given in
the book of Gould and Sribney, "Maximum likelihood
estimation with Stata". However, when checking the code,
stata returns the error message given at the bottom.
The variables in sample1 are named ML_y1 to ML_y5. I would
be grateful if somebody can find the error in my code
. program define itrader
1. version 6
2. args lnf theta1 theta2 theta3 theta4
3.
. tempvar w q v
4. quietly gen double `w' =
exp(ln(1-`theta1')-2*`theta3'*$ML_y3 + ($ML_y1 +
$ML_y2)*ln(`theta3'*$ML_y3) -
> $ML_y4 - $ML_y5)
5. quietly gen double `q' =
exp(ln(`theta1'*`theta2') - 2*`theta3'*$ML_y3 -
`theta4'*$ML_y3 + $ML_y1*ln(`th
> eta3'*$ML_y3) + $ML_y2*ln((`theta4' + `theta3')*$ML_y3)- $ML_y4 - $ML_y5)
6. quietly gen double `v' =
exp(ln(`theta1'*(1-`theta2')) - 2*`theta4'*$ML_y3 -
`theta3'*$ML_y3 + $ML_y1*ln
> ((`theta4' + `theta3')*$ML_y3) + $ML_y2*ln(`theta3'*$ML_y3)- $ML_y4 - $ML_y5)
7.
. quietly replace `lnf' = `w' + `q' + `v'
8. end
.
. use
"C:\DOKUME~1\JUANMA~1\EIGENE~1\prog\MATHEP~1\Stata8se\sample1.dta"
. ml model lf itrader () () () ()
.
end of do-file
. ml check
Test 1: Calling itrader to check if it computes log
likelihood and
does not alter coefficient vector...
FAILED; itrader returned error 133.
Here is a trace of its execution:
------------------------------------------------------------------------------
-> itrader __000009 __000005 __000006 __000007 __000008
- `begin'
= capture noisily version 8: itrader __000009
__000005 __000006 __000007 __000008
-----------------------------------------------------------------------------------
begin itrader ---
- version 6
- args lnf theta1 theta2 theta3 theta4
- tempvar w q v
- quietly gen double `w' =
exp(ln(1-`theta1')-2*`theta3'*$ML_y3 + ($ML_y1 +
$ML_y2)*ln(`theta3'*$ML_y
> 3) - $ML_y4 - $ML_y5)
= quietly gen double __00000A =
exp(ln(1-__000005)-2*__000007* + ( + )*ln(__000007*) - -
)
Unknown function +()
-------------------------------------------------------------------------------------
end itrader ---
- `end'
= set trace off
------------------------------------------------------------------------------
Fix itrader.
r(133);
*
* 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/