我给出的方案代码如下:
- ******生成模拟数据*****
- clear
- set obs 1000
- set seed 123456
- gen e=rnormal(0 1)
- gen x=rnormal(2.8 1)
- gen y=-0.5*x^2+3.2*x-1.42+e
- ******我给的命令画图*******
- #delimit ;
- twoway qfitci y x, stdf clcolor(red*1.2)
- xline(3.2,lcolor(red*1.2))
- legend(off) xlabel(0(1)6) ylabel(,grid)
- xtitle("Log(# of partners)") ytitle("Networking Impacts")
- title("Predictive margins with 95% confidence interval")
- scheme(s1mono);
- #delimit cr
论坛中的大神黄河泉老师也给出了方案,这里一并列出,方便大家参考:
- ******黄河泉老师给的命令******
- reg y x c.x#c.x
- marginscontplot x ,ci
最终效果图如下:
怎么样,带有置信区间的stata绘图你会了吗?如果觉得对你有用的话,评分点赞支持一下哦!