怎么没人回复
我是听了stata高级班后试着做的,水平有限,总是出差错。
以下是我的程序原文,麻烦哪位高手给指出错误的地方吧,感激万分啊。
cap program drop nlirr
program define nlirr
version 10.0
syntax varlist [if],at(name)
local y: word 1 of `varlist'
forvalues i=1(1)46 {
local x`i': word `i'+1 of `varlist'
}
tempname R
scalar `R'=`at'[1,1]
/*left side of the equation:sigma sum*/
forvalues j=1(1)40{
tempvar b`j'
gen double b`j'=1/(1+`R')^`j'
}
/*right side of the equation*/
tempvar c1 c2 c3 c4 c5
gen double `c1'=((1+`R')^3-1)/`R'
gen double `c2'=((1+`R')^6-(1+`R')^3)/`R'
gen double `c3'=((1+`R')^4-1)/`R'
gen double `c4'=((1+`R')^7-(1+`R'^4))/`R'
gen double `c5'=((1+`R')^10-(1+`R')^7)/`R'
replace `y'=`x1'*`b1'+`x2'*`b2'+`x3'*`b3'+`x4'*`b4'+`x5'*`b5'+`x6'*`b6'+`x7'*`b7'+`x8'*`b8'+`x9'*`b9'+`x10'*`b10'///
+`x11'*`b11'+`x12'*`b12'+`x13'*`b13'+`x14'*`b14'+`x15'*`b15'+`x16'*`b16'+`x17'*`b17'+`x18'*`b18'+`x19'*`b19'+`x20'*`b20'///
+`x21'*`b21'+`x22'*`b22'+`x23'*`b23'+`x24'*`b24'+`x25'*`b25'+`x26'*`b26'+`x27'*`b27'+`x28'*`b28'+`x29'*`b29'+`x30'*`b30'///
+`x31'*`b31'+`x32'*`b32'+`x33'*`b33'+`x34'*`b34'+`x35'*`b35'+`x36'*`b36'+`x37'*`b37'+`x38'*`b38'+`x39'*`b39'+`x40'*`b40'///
-(`x41'*`c1'+`x42'*`c1'+`x43'*`c2'+`x44'*`c3'+`x45'*`c4'+`x46'*`c5'+1)
end