我想在一個邊際圖中繪製margins
命令產生的邊距,但是從不同的margins
估算中得出。重要的限制:這些係數在相同的最小和最大範圍內,因此是可比的。我怎麼做?Stata中的一個邊緣圖中的幾個邊距的圖形
這裏是一個代碼示例:
webuse nhanes2, clear
tnbreg psu weight hdresult iron, iterate(5) // I am using this regression type so I stick with it here
我知道,我可以把所有的利潤響應曲線在一個情節
margins, dydx(*)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter)
但事實上,我爲每個連續3個margins
命令因爲我想比較一下這個迴歸因素是否會有所不同。代碼因此是
foreach var in weight hdresult iron {
* Procedure to get the numbers for margins right
quietly summarize `var '
local max = r(max)
local step = round(r(max)/6)
quietly margins, at(`cvar'=(1(`step')`max'))
marginsplot, title("") ytitle("")
}
這給了我三個單獨的文件。但是當然,我需要用不同顏色的單個圖形中的所有線條。
任何建議如何做到這一點?