2

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

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

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

我的代码是:

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

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

4

1 回答 1

4

您可以手动编辑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。祝你好运!

于 2021-04-29T10:45:39.137 回答