You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何存储Stata margins估计的置信区间及交互项边际估计值?

Stata边际估计值存储与交互项边际估计问题

一、单变量边际效应的存储与展示(含p值、置信区间)

你代码中的核心问题是拼写错误:将est store和esttab误写为iest store和iesttab,这导致无法正确调用估计结果的统计量。修正后即可完整存储并展示边际效应的p值、置信区间等信息:

正确代码示例

// 估计Y1对X的probit模型,计算X的边际效应并存储
probit Y1 X
margins, dydx(X) post  // post选项将边际效应的所有统计量存入当前结果集
est store m1

// 重复Y2的分析
probit Y2 X
margins, dydx(X) post
est store m2

// 展示基本估计值
esttab m1 m2

// 同时展示置信区间、标准误、p值和显著性星号
esttab m1 m2, ci se p star(* 0.1 ** 0.05 *** 0.01)

说明

margins, dydx(X) post会将边际效应的估计值、标准误、z值、p值、置信区间全部写入当前估计结果集,est store会完整保存这些信息。esttab的ci/se/p选项可以分别调出置信区间、标准误和p值,star()可添加显著性标记。


二、交互项边际估计值的存储

对于交互项的边际估计,同样可以通过post+est store存储结果,或直接用margins的save()选项导出到数据集:

方法1:用est store存储并展示

probit Y2 year month year*month
margins year#month, asbalanced post  // 计算交互项的边际效应并post
est store int_margins  // 存储交互项的边际估计结果

// 展示交互项的边际效应及相关统计量
esttab int_margins, ci se p star(* 0.1 ** 0.05 *** 0.01)

方法2:直接导出到数据集

如果需要将交互项的边际估计结果保存为Stata数据集,可使用margins的save()选项:

probit Y2 year month year*month
margins year#month, asbalanced save("interaction_margins.dta", replace)

执行后会生成一个新数据集,包含交互项组合、边际估计值、标准误、置信区间上下限等所有统计量。


内容的提问来源于stack exchange,提问作者lfreeman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 03:20:16