2
votes

I am using the coefplot command in Stata to plot coefficients and confidence intervals from multiple regression models. I am plotting the same coefficient (X) from 4 different model specifications.

There is one model specification (alternative standard errors) that I cannot figure out how to estimate in Stata, but am able to estimate using R. That means that for one model specification, I have the standard error in R, but not in Stata.

Is there an easy way to manually alter the standard errors in coefplot?

My code is:

coefplot A B C D, drop(_cons) xline(0) keep(X)

How can I add to this code that the standard errors for coefficient X in model D should be Z?

1
Might I ask what kind of "alternative standard errors" you are using?JR96
An alternative work-around is to combine a rcap plot and a scatter plot using twoway to produce a plot similar to that produced by coefplot. The downside is that you may need to manually specify the desired coefficients and upper and lower bounds using input. Happy to provide an example if that would be useful to you.Cybernike
Coefplot has se and ci options where it appears that you can create a matrix with ci's / se's and use that as an input instead of the default e(V).Wouter

1 Answers

4
votes

You can manually edit the e(V) (variance-covariance matrix) and e(b) vectors. For this, define a program:

est restore estimates1

 capture program drop changeeV
 program changeeV, eclass
   tempname b V 
   matrix `b' = e(b)
   matrix `V' = e(V)
   matrix `V'[1,1] = 1.1 // Add values of new variance-covariance matrix
   matrix `b'[1,1] = 10 // Add new coefficient vector
   ereturn post `b' `V' // Repost new vectors 
   ereturn local cmd "reg outcome treatment covariates"
          // Repost initial command (required)
 end
changeeV // Execute program

est store eaX  // Store new generated estimtes

Note that, to reach the covariance matrix, you need to take the square of the standard errors from your output in R. Good luck!