全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
577 0
2024-03-30
想请问一下,关于负二项回归模型的交互效应,画简单斜率图的方法与画线性回归模型的代码时一样的吗?

-回归模型及简单斜率:
clear
sysuse auto,clear
regress price c.length##c.mpg   //调节效应回归
est sto regression   //保存结果
//分别求自变量与调节变量加减一个标准差的值
foreach v of var length mpg {
  su `v' if e(sample)
  local low_`v'=r(mean)-r(sd)
  local high_`v'=r(mean)+r(sd)
}
est restore regression
//调取保存的回归结果
margins,at(mpg=(`low_mpg' `high_mpg') length = (`low_length' `high_length'))  //计算边际效应
marginsplot , xlabel(`low_mpg' "Low IV" `high_mpg' "High IV")
                          ytitle("Dependent variable")
                          ylabel(2000(1000)9000, angle(horizontal) nogrid)
                          graphregion(color(white)) plotregion(margin(l+8 r+8))
                          legend(order(1 "LOW" 2 "HIGH") size(small) col(1) position(11) ring(0) region(fcolor(none) lpattern(blank)))
                          title("") noci



-负二项回归模型:nbreg price c.length##c.mpg
其余的代码是都和上面的线性回归一样吗?
如果想看length取165和210时的简单斜率的数值,是用margins, dydx(mpg) at(length=(165,210)) 还是margins, eydx(mpg) at(length=(165,210))这样呢?

感谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群