截一段讲义供参考:
*-交互项(Wood, Sec6.3, p.194-196)
*-特殊交互项: 平方项 (Wood, Sec6.3, p.189-194)
*-二次函数回顾
*- y = a*x^2 + b*x + c
* 转折点: tpoint = -b/2a
* 边际效果: dy/dx = b + 2a*x
*-转折点的确定
sysuse nlsw88, clear
gen ttl_exp2 = ttl_exp^2
reg wage ttl_exp ttl_exp2
*-the turnning point
global tp = -_b[ttl_exp]/(2*_b[ttl_exp2])
dis "Turn point = " $tp
*-graphing the relationship between y-x
local b0 = _b[_cons]
local b1 = _b[ttl_exp]
local b2 = _b[ttl_exp2]
twoway function y = `b2'*x^2 + `b1'*x + `b0', ///
ytitle("wage") xtitle("ttl_exp") range(0 50) ///
xline($tp,lp(dash))