Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: My program does not accept more than two args


From   francesco manaresi <manaresi@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: My program does not accept more than two args
Date   Sun, 2 May 2010 00:04:25 +0200

This may be obvious, if so I apologize in advance: I am a newbie in programming.
I want to implement a maximum-likelihood estimate, but got problems in
letting the program accept more than 2 arguments (in args).
Consider the simplest case: a normal model. The program is:

***
program define normal
version 1.0
args lnf sigma mu
quietly replace `lnf'=ln( normd(($ML_y1-`mu')/`sigma') ) - ln(`sigma')
end
***
then I should "ml model lf normal equations , "
however it doesn't work. If I check I obtain
***
. ml check
Test 1:  Calling normal to check if it computes log likelihood and
         does not alter coefficient vector...
         FAILED; normal returned error 198.
Here is a trace of its execution:
------------------------------------------------------------------------------
-> normal __000004 __000003
              - `begin'
              = capture noisily version 10.1: normal __000004 __000003

--------------------------------------------------------------------------------------------------------
begin normal ---
                - version 1.0
                - args lnf sigma mu
                - quietly replace `lnf'=ln(
normd(($ML_y1-`mu')/`sigma') ) - ln(`sigma')
                = quietly replace __000004=ln( normd((y-)/__000003) )
- ln(__000003)
y- invalid name

----------------------------------------------------------------------------------------------------------
end normal ---
              - `end'
              = set trace off
------------------------------------------------------------------------------
Fix normal.
r(198);
***
as it can be seen, the program "normal" just considered `lnf' and
`sigma', while it did not consider `mu'.
Similar results are obtained if I switch position of `mu', `sigma', or
`lnf': the third macro is always not considered.
What am I mistaking?
Thank you very much,
Francesco Manaresi

*
*   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   |   Site index