我正在 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/