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 <[email protected]>
To
[email protected]
Subject
Re: st: mm_root arguments limitation issue
Date
Sat, 30 Jul 2011 10:00:00 -0400
Rajesh <[email protected]>:
Copy the code directly to a new file, edit and rename, and save as a
new compiled object; see also
help mata_mosave
Are you specifying a lower bound for your search interval of 100 and
an upper bound of -150??
Why don't you just put
mm_root(x=.,&y(),-300,600,0,1000,...
On Sat, Jul 30, 2011 at 9:30 AM, Tharyan, Rajesh <[email protected]> wrote:
> Dear Austin
>
> Thanks very much for the suggestions. Must say that I had in fact reused some of your code from a previous message re roots. Thanks for that post.
>
> But I still have a problem. which is the file to edit? From the help file, i can see the source code but i cannot see anyway to edit this. When i click on the link to the source code in the help file it just opens this in the viewer. Also i am not sure where this program is being saved or indeed what it is called.
>
> Re the roots, In one version of the program I am backing out growth rates rather than a discount rate, due to some odd data the growth rate vary widely say from 300% to -150%. So if i specify say r=mm_root(x=.,&y(),100,-150,0,1000, i get the some values as 100 when they should be 150.
>
> Regards
> rajesh
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Austin Nichols
> Sent: 30 July 2011 13:52
> To: [email protected]
> Subject: Re: st: mm_root arguments limitation issue
>
> Rajesh <[email protected]>:
> 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 <[email protected]> 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/