Dear Stata Users,
I wish to modify the following code from a previous question to fit my case. The code runs well but for the final stage, where I receive the following failed message. I do not have any background in coding and would appreciate any assistance from experts.
This is the code that's failing.
The following is my sample data file
I wish to modify the following code from a previous question to fit my case. The code runs well but for the final stage, where I receive the following failed message. I do not have any background in coding and would appreciate any assistance from experts.
invalid varlist
r(198);
end of do-file
r(198);
end of do-file
Code:
sqreg logGDPC logTEA logGFCF logEXP logINF logUNEM, quantile(.1 .2 .3 .4 .5 .6 .7 .8 .9) reps(100) preserve gen q = _n*10 in 1/9 foreach var of varlist logTEA logGFCF logEXP logINF logUNEM { gen _b_`var' = . gen _lb_`var' = . gen _ub_`var' = . gen _vb_`var' = . gen _pb_`var' = . local i = 1 foreach q of numlist 10(10)90 { replace _b_`var' = _b[q`q':`var'] in `i' replace _lb_`var' = _b[q`q':`var'] - _se[q`q':`var']*invnormal(.975) in `i' replace _ub_`var' = _b[q`q':`var'] + _se[q`q':`var']*invnormal(.975) in `i++' replace _vb_`var' = _b[q`q':`var'] + _se[q`q':`var']*invnormal(.975) in `i+++' replace _pb_`var' = _b[q`q':`var'] + _se[q`q':`var']*invnormal(.975) in `i++++' } } keep q _b_* _lb_* _ub_* _vb_* _pb_* keep in 1/9 reshape long _b_ _lb_ _ub_ _vb_ _pb_, i(q) j(var) string set scheme s1color twoway rarea _lb_ _ub_ q, astyle(ci) yline(0) acolor(%90) || /// line _vb_ _pb_ q, /// line _b_ q, /// by(var, yrescale xrescale note("") legend(at(4) pos(0))) /// legend(order(2 "effect" /// 1 "95% confidence" "interval") /// cols(1)) /// ytitle(Effect on GDPC) /// ylab(,angle(0) format(%7.0gc)) /// xlab(10(10)90) xtitle(percentile of GDPC) restore
The following is my sample data file
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long ID int time float(logGDPC logTEA logGFCF logEXP logINF logUNEM) 1 2013 7.621223 7.502187 3.724844 4.010553 .6453776 1.5106215 1 2014 7.653598 7.924435 3.768649 4.141443 -.032325238 1.411816 1 2015 7.641711 8.642591 3.7145524 3.901595 .50066805 1.4131223 1 2016 7.645064 8.719317 3.67619 4.011864 -.18893985 1.426973 1 2017 7.670767 8.737132 3.848434 3.9972446 1.3948933 1.38585 1 2018 7.706368 8.710455 3.948156 3.999761 .7880386 1.2555672 1 2019 7.7439 8.835502 3.9197176 4.0825214 -.13332224 1.206682 1 2020 7.753374 8.995661 3.921036 3.683746 1.8500146 1.325331 2 2017 7.202292 8.679312 3.733577 3.969207 1.261925 2.260777 2 2018 7.238562 8.829372 3.697694 4.0287995 1.47467 2.260573 3 2006 9.341407 9.492055 3.703087 4.6403537 3.144008 3.5727994 3 2007 9.378068 9.541512 3.895416 4.72719 2.660388 3.522266 3 2008 9.389768 9.70808 3.92811 4.5423913 3.238006 3.4788275 3 2009 9.216717 9.994699 4.037871 4.272424 2.783666 3.4782116 3 2010 9.292528 10.059893 3.9809356 4.434529 2.6419246 3.5772746 3 2011 9.33862 10.1148 4.1014805 4.4829507 2.835395 3.587216 3 2012 9.317701 10.385543 4.1425543 4.5669575 2.7216465 3.574088 3 2013 9.403932 10.315067 4.0112476 4.81036 2.479623 3.588321 3 2014 9.440065 10.525192 3.9300625 4.808782 2.2001188 3.606809 3 2015 9.370712 10.758413 3.993482 4.66533 1.8617316 3.6325445 end format %ty time label values ID ID label def ID 1 "BEN", modify label def ID 2 "BFA", modify label def ID 3 "BWA", modify
Comment