0
votes

I have executed the code snippet below:

foreach yr in 2000 2001 2002 2003 2004 2005 2006 {
    eststo: ivregress 2sls y (var=z) c [aw=w] if yr==`yr'
    estimate store r`yr'
}

coefplot r2000 r2001 r2002 r2003 r2004 r2005 r2006 , vertical keep(var)

This produced the following graph:

enter image description here

However, I want to change the label in x-axis to 2000, 2001, ..., 2006.

As you can see, I am using the community-contributed commandcoefplot but these coefficients are from separate regressions, and 2000 or 2001 are not variable names.

Is there any way to work around this?

1

1 Answers

1
votes

Using Stata's auto toy dataset:

sysuse auto, clear
recode foreign (0 = 1) (1 = 2)

forvalues i = 1 / 2 {
    eststo: regress mpg price if foreign == `i'
    estimate store r`i'
}

The following does the trick:

coefplot (r1 \ r2), vertical keep(price) aseq swapnames

enter image description here

Or with custom labels:

coefplot (r1, aseq(Foreign 1) \ r2, aseq(Foreign 2)), vertical keep(price) swapnames

enter image description here