应用stata做统计分析,214页的例题:
regress y3 x3
predict yhat3o
label variable yhat3o "OLS regression (regress)"
qreg y3 x3, nolog
predict yhat3q
label variable yhat3q "median regression (qreg)"
rreg y3 x3,nolog
predict yhat3r
label variable yhat3r "robust regression (rreg)"
graph twoway scatter y3 x3
line yhat3o x3, clpattern(solid) sort
line yhat3r x3, clpattern(longdash) sort
line yhat3q x3, clpattern(shortdash) sort , ytitle("y3 = 10 + 2*x + e3") legend(order(4 3 2) position(5) ring(0) cols(1) margin(sides)) ylabel(-30(10)30)
结果如图所示: