Coefplot-Graph point estimates and confidence intervals from different regressions

253 Views Asked by At

In Stata, I am running the same regression 5 times, with each regression covering a separate time interval. I previously have stored the coefficient of interest after each regression like so:

local coef1=_b[x1] 

I then place all the coefficients in a matrix to graph using coefplot:

matrix Z = (`coef1',`coef2',`coef3',`coef4',`coef5',`coef6')

coefplot (matrix(Z), ciopts(recast(rcap)) base vertical noci recast(connected) xlabel(1 "P1" 2 "P2" 3 "P3" 4 "P4" 5 "P5" 6 "P6") yline(0) name(Fig000) xtitle(Time intervals) ytitle(Coefficient)

How can I also store and graph the confidence intervals for each point estimate of interest on the same graph?

1

There are 1 best solutions below

2
joshb On

The best way to store CIs depends on the command you use to run your regression.

Many regression commands will produce a matrix called r(table), which will include the CIs. You can then save the matrix and/or access elements of it, including the point estimate and CIs.

Some regression commands do not produce r(table). In this case, you can calculate your CIs directly from the point estimate (_b[x1]), standard error (_se[x1]) and degrees of freedom (e(df_r)), which can all be accessed after the regression. So for example for storing 95% CIs after the regression:

local lower = _b[x1] - invt(e(df_r),0.975)*_se[x1]
local upper = _b[x1] + invt(e(df_r),0.975)*_se[x1]