I have a long list of variable names stored in a global. I use these to perform a series of regressions in models excluding and including control variables. I want to plot the coefficients but don't want to write out each coefficient name when using -coefplot. For simplicity I just use three variable names in the example:
Now my coefficients are stored with the names
so writing
won't do, because I need the prefixes 'naiv_' and 'cov_'. So how do I make two new globals, which are the elements in $y with the prefix 'naiv_' and 'cov_', which I then can use the plot the coefficients from the different models? Ultimately I would like to end up with two plots, 1) containing the coefficients from all the models excluding control variables, 2) contatining the coefficients from all models including control variables.
Code:
global y y1 y2 y3 foreach y of varlist $y{ reg `y' x estimates store naiv_`y' reg `y' x z1 z2 z3 estimates store cov_`y' }
Code:
naiv_y1 naiv_y2 naiv_y3 cov_y1 cov_y2 cov_y3
Code:
coefplot $y
Comment