Hello. I am trying to generate confidence interval for some regressed variables. This is the code:
use "$DATA\Data_US_v2_shocksalllagqe.dta", clear
gen h = t-1
foreach var in lrgdp lvix lneer {
forvalues i = 1/7 {
foreach iv in mp1 mp2 mp3 mp4 ff1 ff2 ff3 ff4 ed1 ed2 ed3 ed4 {
foreach pi in t3m t6m t1y t2y t3y t5y t7y t10y {
ivreg2 `var' l(1/3).`var' (`pi'_e=`iv') l(1/3) `pi' l(0/3).qe , r bw(auto)
*ivreg2 `var' l(1/3).`var'_qe (`pi'_e_qe=`iv'_qe ) l(1/3).`pi'_e_qe l(0/3).qe , r bw(auto)
*ivreg2 `var' l(1/3).`var'_nqe (`pi'_e_nqe=`iv'_nqe ) l(1/3).`pi'_e_nqe l(0/3).qe , r bw(auto)
gen b`var'h`i' = _b[`pi'_e]
gen se`var'h`i' = _se[`pi'_e]
quietly replace b`var' = b`var'h`i' if h==`i'
quietly replace up90b`var' = b`var'h`i' + 1.68*se`var'h`i' if h==`i'
quietly replace lo90b`var' = b`var'h`i' - 1.68*se`var'h`i' if h==`i'
}
}
}
}
The problem is when generating b`var'h`i' variables. Stata says that the variable is already defined but I have checked the dta file and there's not a variable with this name. I also tried to change the name of the variables b`var'hì' by adding and A at the beggining at there is the same problem.
Anyone knows what is wrong with that??
Thank you for your help.
Related Posts with Already defined variable in a loop
Customize the width of columns in tables using putdocxHi all, I'm having difficulty determining if and how putdocx can create a table with explicitly set…
How can I export different tables to excel using different sheets?Hi, I'm having a hard time trying to export three different tabstats to three different excel sheets…
How can I keep a large a number of variables in STATAHello, I would like to do the OLS after variables selection by LASSO. Lasso selected about 70 varia…
xtabond2: change in results when dropping the first two periodsHi everyone, I am using xtabond2 to run difference and system GMM regressions. I'm working in Stata…
to convert data into unique observationArray Hello, i am new to stata and i'm working on unbalanced panel. i have uploaded image of data.…
Subscribe to:
Post Comments (Atom)
0 Response to Already defined variable in a loop
Post a Comment