想请问一下,关于负二项回归模型的交互效应,画简单斜率图的方法与画线性回归模型的代码时一样的吗?
-回归模型及简单斜率:
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))这样呢?
感谢!