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: RE: My program does not accept more than two args


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: My program does not accept more than two args
Date   Mon, 3 May 2010 17:06:34 +0100

Although you got suggestions of alternative code, your problem was not addressed. 

Your own trace shows that -normal- only receives two arguments. 

normal __000004 __000003

Here __000004 __000003 are temporary names. 

Its willingness to process three or more was not the issue. The problem arises from how it was called. 

Nick 
[email protected] 

francesco manaresi

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?

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index