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]

From |
Austin Nichols <[email protected]> |

To |
[email protected] |

Subject |
Re: st: mm_root arguments limitation issue |

Date |
Thu, 1 Sep 2011 07:50:30 -0400 |

Ben Jann is the author of mm_root, distributed in -moremata- on SSC. Note that the FAQ advises you to give the source of user-written software. Ben wrote me on another occasion: " the limit of 10 passthrough arguments comes from mm_callf() which is used in mm_root(). But this is not really a limitation. In fact, one single passthrough argument would suffice, since you can put everything into one object and then have the called function take the object apart. In you case, you could type something such as function y(x, v) { a=v[2]; b=v[3]; c=v[4]; d=v[5]; e=v[6]; f=v[7] g=v[8]; h=v[9]; i=v[10]; j=v[11]; k=v[12] return((-1*(a-b)*(1+x)^5) + ((c-(b*x))*(1+x)^4) + ((d-(e*x))*(1+x)^3) + ((f-(g*x))*(1+x)^2) + ((h-(i*x))*(1+x)) + ((j-(k*x))) + ((j-(k*x))/x)) } for (i=1; i<=rows(v); i++) { r = mm_root(x=., &y(), 0, 1, 0, 1000, v[i,.]) v[i,1] = x } In more complicated situations, v could be a pointer vector or a structure containing different types of elements. [One may face] a problem with solutions outside the specified search interval. In such a case mm_root() will issue an appropriate return code that can be used to trigger another search with a different interval. Say you search over interval [0,100] and mm_root() returns code 3 then you could have your program start a new search, say, between 100 and 200. And so on. For example, code something like lo = 0 up = 100 while (1) { r = mm_root(x=., &y(), lo, up, ...) if (r=2) { lo0 = lo lo = lo - (up-lo) up = lo0 } else if (r=3) { up0 = up up = up + (up-lo) lo = up0 } else { break } } " On Thu, Sep 1, 2011 at 1:38 AM, dai_yunhao <[email protected]> wrote: > Hi everybody > > I'm a new user of stata, and facing the problem about the mm_root arguments > limitation issue. > I try to find the source code of mm_root and copy the code to a new file, > for the issue, I change the first line of the source code > local opts "o1, o2, o3, o4, o5, o6, o7, o8, o9, o10 " > to > local opts "o1, o2, o3, o4, o5, o6, o7, o8, o9, > o10,o11,o12,o13,o14,o15,o16,o17,o18,o19,o20,o21,o22,o23,o24,o25,o26,o27,o28,o29,o30" > > My question is : > 1 Do I correctly change the code? > 2 Which format should I save the new file to ? Should I click the menu > file-->save as-->filename.ado? > > Thank you! > > Dai Yunhao > > * * 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/

**References**:**st: mm_root arguments limitation issue***From:*dai_yunhao <[email protected]>

- Prev by Date:
**Re: st: Polynomial Fitting and RD Design** - Next by Date:
**Re: st: RE: esttab question** - Previous by thread:
**Re: st: mm_root arguments limitation issue** - Next by thread:
**st: esttab question** - Index(es):