Hallo! I am trying to implement the following program to obtain iterated nonlinear combinations of estimated parameters along with their bootstrap standard errors. I need 20 iterations, however after 10 i get the "expression too long" error message. I am aware of the problem (I read related discussions here in statalist) and I see that my routine is all but efficient. But after several trials I did not get the solution. Anybody can kindly help me out? Many thanks!
use data.dta, clear
program define iterpro, rclass
reg y x z
local b0=1
local b1 "(_b[x]*`b0' + _b[z]*`b0')"
local b2 "(_b[x]*`b1' + _b[z]*`b0')"
local b3 "(_b[x]*`b2'+_b[z]*`b1')"
local b4 "(_b[x]*`b3'+_b[z]*`b2')"
local b5 "(_b[x]*`b4'+_b[z]*`b3')"
local b6 "(_b[x]*`b5'+_b[z]*`b4')"
local b7 "(_b[x]*`b6'+_b[z]*`b5')"
local b8 "(_b[x]*`b7'+_b[z]*`b6')"
local b9 "(_b[x]*`b8'+_b[z]*`b7')"
local b10 "(_b[x]*`b9'+_b[z]*`b8')"
nlcom (a1: _b[x]*`b10') (a2:_b[z]*`b9'), post
nlcom (b11: _b[a1] + _b[a2])
tempname b
matrix `b' = r(b)
return scalar beta = `b'[1,1]
exit
end
bootstrap r(beta), reps(10) seed(1234): iterpro
estat bootstrap
use data.dta, clear
program define iterpro, rclass
reg y x z
local b0=1
local b1 "(_b[x]*`b0' + _b[z]*`b0')"
local b2 "(_b[x]*`b1' + _b[z]*`b0')"
local b3 "(_b[x]*`b2'+_b[z]*`b1')"
local b4 "(_b[x]*`b3'+_b[z]*`b2')"
local b5 "(_b[x]*`b4'+_b[z]*`b3')"
local b6 "(_b[x]*`b5'+_b[z]*`b4')"
local b7 "(_b[x]*`b6'+_b[z]*`b5')"
local b8 "(_b[x]*`b7'+_b[z]*`b6')"
local b9 "(_b[x]*`b8'+_b[z]*`b7')"
local b10 "(_b[x]*`b9'+_b[z]*`b8')"
nlcom (a1: _b[x]*`b10') (a2:_b[z]*`b9'), post
nlcom (b11: _b[a1] + _b[a2])
tempname b
matrix `b' = r(b)
return scalar beta = `b'[1,1]
exit
end
bootstrap r(beta), reps(10) seed(1234): iterpro
estat bootstrap
Comment