2017-04-19 244 views
2

我想,以顯示彼此下選擇兩次迴歸係數(用他們的置信區間)。 使用本Jann的不錯coefplotssc install coefplot),我可以創建一個子圖僅在所有車型的所有係數都包括一個圖表,但我不通過模型,而不是由係數訂購係數成功。coefplot:幾種模式與幾個係數每一個圖形

可替換地,我可以由係數產生具有幾個子圖的曲線圖,這是不我需要:應該只有一個子圖,並且爲係數的公共比例。

這裏來說明我的需要的最小例子,我剛纔描述:

sysuse auto.dta, clear 
reg price mpg rep78 
eststo model1 
reg price mpg rep78 weight 
eststo model2 

*what do I have: 2 models with 2 coefficients each (plus constant) 

*what do I want: 1 graph with 2 models beneath one another, 
       *2 coefficients per model, 1 colour and legend entry per coefficient (not model!) 
       *common scale 

*what is easy to get: 

coefplot model1 model2, ///1 graph with all coefficients and models, 
    keep(mpg rep78)   //but order is by coefficient, not by model 
          //how to add model names as ylabels? 

*or 1 graph with 2 subgraphs by coefficient: 
coefplot model1 || model2, /// 
    keep(mpg rep78) bycoefs  

誰能幫助我獲得最佳的使用coefplot我想要的圖形?

正如你可以從例如筆記讀,完美的解決方案將包括一個顏色,每種係數圖例項(不模型),並使用型號名稱的ylabels,但這是次要的。

我已經嘗試了幾個coefplot選項,但在我看來,它們大多數是來自一個模型的幾個方程,而不是來自不同模型的係數。

回答

0

我不知道該如何處理的型號名稱,但對你的問題的第一部分,在我看來,你可能只是這樣做:

sysuse auto.dta, clear 
reg price mpg rep78 
eststo m1 
reg price mpg rep78 weight 
eststo m2 


coefplot (m1) || (m2), /// 
drop(_cons) byopts(row(2)) keep(mpg rep78) 

還是我誤解你想?