在 Stata coefplot

问题描述

我在 Stata 中使用 coefplot 命令绘制多个回归模型的系数和置信区间。我正在绘制来自 4 个不同型号规格的相同系数 (X)。

一个模型规范(替代标准误差),我无法弄清楚如何在 Stata 中进行估计,但可以使用 R 进行估计。这意味着对于一个模型规范,我在 R 中有标准误差,但没有在 Stata 中。

是否有一种简单的方法可以手动更改 coefplot 中的标准误差?

我的代码是:

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

如何在此代码添加模型 D 中系数 X 的标准误差应为 Z?

解决方法

您可以手动编辑 e(V)(方差-协方差矩阵)和 e(b) 向量。为此,定义一个程序:

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

请注意,要获得协方差矩阵,您需要从 R 中的输出中取标准误差的平方。祝你好运!