我目前在利用stata处理一篇数据,自己模仿着前人写了一个myfile.ado程序,如下:
program define myfile
version 12.0
if "`1'"=="?"{
#delimit;
global S_1" a_own a_klq a_lns a_gro a_roa a_vol
a_y1 a_y2 a_y3 a_y4 a_y5 a_y6 a_y7 a_y8
a_0
b_own b_lns b_gro
b_y1 b_y2 b_y3 b_y4 b_y5 b_y6 b_y7 b_y8
b_0
"
#delimit cr
global S_2="Estimation for dynamic capital structure"
global a_own=0.0244903
global a_klq=-0.2627165
global a_lns=0.1550744
global a_gro=-0.0081462
global a_roa=-0.5033987
global a_vol=0.0035327
global a_y1=-0.00355
global a_y2=-0.0058018
global a_y3=-0.0422345
global a_y4=-0.0687259
global a_y5=-0.0691767
global a_y6=-0.0969726
global a_y7=-0.1291547
global a_y8=-0.1728774
global a_0=-2.583166
global b_own=-16.35691
global b_lns=-10.53241
global b_gro=1.969877
global b_y1=-16.78091
global b_y2=-13.23997
global b_y3=-107.7703
global b_y4=-10.30623
global b_y5=-7.182714
global b_y6=-6.755521
global b_y7=-3.615221
global b_y8=0
global b_0=241.2516
exit
}
#delimit;
replace tl_star = $a_own*owner +$a_klq*kliq +$a_lns*lnsize +$a_gro*gro +$a_roa*roa +$a_vol*vola +$a_y1*y2005 +$a_y2*y2006 +$a_y3*y2007 +$a_y4*y2008 +$a_y5*y2009 +$a_y6*y2010 +$a_y7*y2011 +$a_y8*y2012 +$a_0;
replace alpha = $b_own*owner +$b_lns*lnsize +$b_gro*gro +$b_y1*y2005 +$b_y2*y2006 +$b_y3*y2007 +$b_y4*y2008 +$b_y5*y2009 +$b_y6*y2010 +$b_y7*y2011 +$b_y8*y2012 +$b_0;
#delimit cr
if tl_star<0 {
replace tl_star=0
}
else if tl_star>1{
replace tl_star=1
}
replace `1'=(1-alpha)* tl_lag +alpha* tl_star
end
然后在引用时输入了如下命令:
*用非线性最小二乘法估计非线性模型
cap drop alpha
gen tl_star = 0
gen alpha = 0
drop if tl_lag==.
cap program drop_all
nl myfile tl
est store m_dynamic
但是最后两行命令执行时会报错,如下:
. nl myfile tl
unrecognized command: nlmyfile
nlmyfile refused query, rc=199
r(199);
请问是哪里出了问题呢?求教各位大神支招。