接着上面的回答,在使用outreg2 using myreg, cells(x1 x3) replace时报错option cells() not allowed
时间: 2024-03-11 13:47:50 浏览: 25
非常抱歉,我的回答有误。在 Stata 中,`outreg2` 命令不支持 `cells()` 选项,因此会出现错误提示 "option cells() not allowed"。
如果您想要只保存自己感兴趣的变量的回归系数,可以使用 `putdocx` 命令。具体步骤如下:
1. 进行回归分析,例如:
```
reg y x1 x2 x3 x4
```
2. 使用命令 `matrix list e(b)` 查看回归系数矩阵,例如:
```
matrix list e(b)
```
这个命令可以将回归系数矩阵输出到 Stata 界面上。
3. 使用命令 `putdocx` 只保存自己感兴趣的变量的回归系数,例如:
```
putdocx myreg.docx, replace
putdocx "regression coefficients for x1 and x3" " " " " ///
(e(b)[1.colnumb(x1) 1.colnumb(x3)], fmt(%9.3f)) ///
(e(V)[1.colnumb(x1) 1.colnumb(x3),1.colnumb(x1) 1.colnumb(x3)], fmt(%9.3f)) ///
(e(se)[1.colnumb(x1) 1.colnumb(x3)], fmt(%9.3f)) replace
```
这个命令会将变量 `x1` 和 `x3` 的回归系数保存到名为 `myreg.docx` 的 Word 文件中,覆盖原有文件。
4. 使用命令 `shell` 或者在文件管理器中打开 `myreg.docx` 文件,查看保存的回归系数,例如:
```
shell open myreg.docx
```
或
在文件管理器中双击 `myreg.docx` 文件
这个命令会打开名为 `myreg.docx` 的 Word 文件,并显示回归系数。