# 回归结果转 Word / Regression results to Word

本例由官方 Stata 19.5 实际运行，使用合法安装自带的 auto 数据，在 price、weight、mpg 完整的相同 74 个观测上估计两个 OLS 模型，均采用 vce(robust)。本包不含 Stata 软件或 auto 原始数据；系数不作因果解释。

## 复做 / Rerun

1. 解压到新的练习目录，保留一份参考成果。先保存已有 Stata 工作，在独立会话切换到该目录。
2. 运行 `do analysis.do`，核对日志完成标记 `WORD_TABLE_COMPLETED`。clear all 清空本次会话；replace 覆写当前练习目录的同名 CSV、日志和 Word。
3. 从同一目录运行 `python finalize_word.py regression-table.docx`。只需 Python 3 标准库；此步移除默认 Title 的装饰线及维护者元数据，不改任何表格数字。
4. 打开 regression-table.docx。它包含一个 9 行 3 列的原生 Word 表格，可继续改字、改列宽及表注，不是截图。对照 coefficients.csv，确认系数与标准误、N=74、R²及单位。表内显示三位小数；CSV 保留计算精度。

Both OLS models use the same 74 complete cases and heteroskedasticity-robust SEs. The native Word table is editable. It reports rounded coefficients/SEs, observations, R² and notes; absent mpg is labelled Not included, not zero. No significance stars are added. Run Stata `do analysis.do` in a fresh practice session and directory, then Python `finalize_word.py regression-table.docx`. Python uses only the standard library and adjusts title decoration and metadata, not table values. Compare cell values with CSV rather than DOCX ZIP bytes, which can differ across runs.

## 文件与来源 / Files and sources

analysis.do、finalize_word.py、regression-table.docx、coefficients.csv、analysis.log 及实际排版 preview.png。清空内存与覆写行为仅在上述主动复做时发生，打开案例不会自动执行。

官方方法：https://www.stata.com/manuals/rptputdocxintro.pdf
指南：https://marx-max.aidea-labs.com/blog/2026-10-15-regression-to-word/
案例：https://marx-max.aidea-labs.com/cases/regression-to-word/
本次独立计算及文档渲染在 macOS 完成；Windows 真机、用户 Office 配置与模型自动完成本任务未验收。
