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]

Re: st: mm_root arguments limitation issue


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: mm_root arguments limitation issue
Date   Sat, 30 Jul 2011 08:52:29 -0400

Rajesh <R.Tharyan@exeter.ac.uk>:
The limitation to 10 arguments is documented in the help file.  The
source code is documented in
help moremata_source##mm_root
so you can change a few bits of the code, rename the program, and save
your own new N-argument version.

When you say "in such cases the answer is actually different" do you
mean the true solution is in the interior of (0,1) and mm_root returns
0 or 1, or do you mean it is outside the interval?

On Sat, Jul 30, 2011 at 5:26 AM, Tharyan, Rajesh <R.Tharyan@exeter.ac.uk> wrote:
> Hi all
>
> I am trying to run a program  like below,  using Ben Jann's  mm_root function within the moremata program.
>
> ssc install moremata
> clear all
> sysuse auto,clear
> gen y=price/24
> gen z= mpg/12
> g x =.
> mata
> v=J(1,1,.)
> st_view(v,.,"x  price mpg rep78 trunk weight length turn displacement y z headroom") function y(x,a,b,c,d,e,f,g,h,i,j,k) { 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,2],
> v[i,3],v[i,4],v[i,5],v[i,6],v[i,7],
> v[i,8],v[i,9],v[i,10],v[i,11],v[i,12])
> v[i,1]=x
> }
> end
> l in 1/10, noo
>
> I get the following error
>               mm_root():  3001  expected 4 to 16 arguments but received 17
>                 <istmt>:     -  function returned error r(3001);
>
> a look at the help file  seems to suggest that  the number of  additional arguments to pass on to function f is  limited to 10.
>
> Q1. Could  there any particular reason why it is limited to 10?
> Q2. Is there a way to increase the number of options?
> Q3. Setting the
>           lo:  real scalar containing lower endpoint of the search interval
>           up:  real scalar containing upper endpoint of the search interval to 0 and 1 leads to a large number of zeros and 1. cross checking with Excel solver  shows that in such cases the  answer is actually different. Is there a best way to set lo and up values?
>
> Thanks very much for your time
>
> regards
> Rajesh

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