stata - 在 Stata coefplot 中编辑置信区间

标签 stata coefplot

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

有一种模型规范(替代标准误差),我无法弄清楚如何在 Stata 中估计,但可以使用 R 进行估计。这意味着对于一种模型规范,我在 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 中的输出中获取标准误差的平方。祝你好运!

关于stata - 在 Stata coefplot 中编辑置信区间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67306907/

相关文章:

arguments - 批处理模式下的Stata命令行参数

aggregate - 如何在 Stata 中聚合关系数据?

sas - 除 R 以外的其他统计软件包中的 Markdown

stata - 如何使用stata在coefplot中指定不同的xscale?

Stata 系数图 : plot coefficients and corresponding confidence intervals on 2nd axis

r - R 中 coefplot 包中的命令 multiplot 面临错误

stata - 分隔字符串中的数字和单词

stata - 为什么 coefplot 不绘制 Stata 中所有级别的交互?

r - R 中的 coefplot;更改 CI 线颜色

R:基于嵌套循环生成新列