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: The another problem about mm_root
From
dai_yunhao <[email protected]>
To
[email protected]
Subject
st: The another problem about mm_root
Date
Sat, 3 Sep 2011 06:16:23 -0700 (PDT)
Dear Everyone,
Thank you for your suggestion, and I try to use vector to instead for the
argument, there is no error indeed, but this time I face another problem.
My program as follows:
clear all
use gls.dta,clear
gen x=.
mata
v=J(1,1,.)
st_view(v,., "x price b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 froe_1 froe_2
froe_3 froe_4 froe_5 froe_6 froe_7 froe_8 froe_9 froe_10 froe_11 froe_12")
function y(x,v) {
p=v[2];b0=v[3];b1=v[4];b2=v[5];b3=v[6];b4=v[7];b5=v[8];b6=v[9];b7=v[10];b8=v[11];b9=v[12];b10=v[13];b11=v[14];f1=v[15];f2=v[16];f3=v[17];f4=v[18];f5=v[19];f6=v[20];f7=v[21];f8=v[22];f9=v[23];f10=v[24];f11=v[25];f12=v[26]
return(-p+b0+b0*(f1-x)/(1+x)+b1*(f2-x)/(1+x)^2+b2*(f3-x)/(1+x)^3+b3*(f4-x)/(1+x)^4+b4*(f5-x)/(1+x)^5+b5*(f6-x)/(1+x)^6+b6*(f7-x)/(1+x)^7+b7*(f8-x)/(1+x)^8+b8*(f9-x)/(1+x)^9+b9*(f10-x)/(1+x)^10+b10*(f11-x)/(1+x)^11+b11*(f12-x)/(x*(1+x)^11))
}
for (i=1;i<=rows(v);i++) {
r=mm_root(x=.,&y(),0,1,1e-9,1000,v[i,.])
v[i,1]=x
}
end
When I run the program, the value of x is always the missing value ".", I
try to change the interval
e.g.
r=mm_root(x=.,&y(),*-10,10*,1e-9,1000,v[i,.])
but the value of x is -10 or 10, apparently it is not the real valut of x.
Could anyone tell me what's wrong with the program?
Thanks for your help!
Dai Yunhao
--
View this message in context: http://statalist.1588530.n2.nabble.com/The-another-problem-about-mm-root-tp6756596p6756596.html
Sent from the Statalist mailing list archive at Nabble.com.
*
* 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/