Building the same coefficient over time

I use the package coefplotin Stata to calculate how the coefficient changes depending on the model used. In particular, I want to see how the percentage ratio changes over time. I draw it vertically, so the x axis can show the year to which each coefficient relates. However, I cannot properly designate the X axis (instead of showing the name of the variable x1that interests me , it should indicate 1, 2, and 3. I would also like to omit the legend using option legend(off), but this does not work.

This is the code I'm using:

reg y x1 x2 if year==1;
estimates store t1;

reg y x1 x2 if year==2;
estimates store t2;

reg y x1 x2 if year==3;
estimates store t3;

coefplot t1 t2 t3, drop(x2) vertical yline(0);

Any suggestion would be greatly appreciated.

+4
source share
1

, ( ), :

clear
set more off

sysuse auto

reg price weight rep78 if foreign
estimates store foreign

reg price weight rep78 if !foreign
estimates store not_foreign

matrix at = (1 / 2)

coefplot foreign || not_foreign, drop(rep78 _cons) vertical bycoefs

, local. coefplot. , - :

year1 || year2 || ... || yearn

:

coefplot `allyears', drop(<some_stuff>) vertical bycoefs

, :

clear
set more off

use http://www.stata-press.com/data/r12/nlswork.dta

forvalues i = 70/73 {
    regress ln_w grade age if year == `i'
    estimates store year`i'
    local allyears `allyears' year`i' ||
    local labels `labels' `i'
}

// check
display "`allyears'"
display `"`labels'"'

coefplot `allyears', keep(grade) vertical bycoefs bylabels(`labels')

coefplot , statsby graph (help graph).

+3

Source: https://habr.com/ru/post/1611192/


All Articles