代码拉取完成,页面将自动刷新
同步操作将从 连享会/mostly-harmless-replication-基本无害的计量经济学 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
clear all
set more off
/* Set random seed for replication */
set seed 1149
/* Number of random variables */
local nobs = 100
set obs `nobs'
gen x = runiform()
gen y_linear = x + (x > 0.5) * 0.25 + rnormal(0, 0.1)
gen y_nonlin = 0.5 * sin(6 * (x - 0.5)) + 0.5 + (x > 0.5) * 0.25 + rnormal(0, 0.1)
gen y_mistake = 1 / (1 + exp(-25 * (x - 0.5))) + rnormal(0, 0.1)
graph twoway (lfit y_linear x if x < 0.5, lcolor(black)) ///
(lfit y_linear x if x > 0.5, lcolor(black)) ///
(scatter y_linear x, msize(vsmall) msymbol(circle) mcolor(black)), ///
title("A. Linear E[Y{sub:0i}|X{sub:i}]") ///
ytitle("Outcome") ///
xtitle("x") ///
xline(0.5, lpattern(dash)) ///
scheme(s1mono) ///
legend(off) ///
saving(y_linear, replace)
graph twoway (qfit y_nonlin x if x < 0.5, lcolor(black)) ///
(qfit y_nonlin x if x > 0.5, lcolor(black)) ///
(scatter y_nonlin x, msize(vsmall) msymbol(circle) mcolor(black)), ///
title("B. Nonlinear E[Y{sub:0i}|X{sub:i}]") ///
ytitle("Outcome") ///
xtitle("x") ///
xline(0.5, lpattern(dash)) ///
scheme(s1mono) ///
legend(off) ///
saving(y_nonlin, replace)
graph twoway (lfit y_mistake x if x < 0.5, lcolor(black)) ///
(lfit y_mistake x if x > 0.5, lcolor(black)) ///
(function y = 1 / (1 + exp(-25 * (x - 0.5))), lpattern(dash)) ///
(scatter y_mistake x, msize(vsmall) msymbol(circle) mcolor(black)), ///
title("C. Nonlinearity mistaken for discontinuity") ///
ytitle("Outcome") ///
xtitle("x") ///
xline(0.5, lpattern(dash)) ///
scheme(s1mono) ///
legend(off) ///
saving(y_mistake, replace)
graph combine y_linear.gph y_nonlin.gph y_mistake.gph, ///
col(1) ///
xsize(4) ysize(6) ///
graphregion(margin(zero)) ///
scheme(s1mono)
graph export "Figure 6-1-1-Stata.png", replace
/* End of file */
exit
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。