2014-09-25 313 views
0

我正在嘗試此代碼(下面),Stata似乎讀取它 - 它不顯示任何錯誤 - ,但它不會生成任何變量。那就是:在Stata中繪製兩個累積分佈

cumul price if dummy==1, gen(cprice1)

cumul price if dummy==0, gen (cprice2)

line cprice1 cprice2 price

難道你們能幫我嗎?我可以用虛擬條件「if」來描繪兩個內核密度分佈,使用一個類似的代碼,在後者中存儲結果以供後者繪製它們 - 遵循Stata中的幫助文件。但我無法用累積分佈來做到這一點。

+0

在'幫助cumul'的例子工作得很好。試試看。如果你沒有給出一個可重複的例子,很難弄清楚什麼是錯的。 – 2014-09-25 23:54:58

+0

* Stata Journal *中的'distplot'支持累積分佈圖。 Stata中的「搜索distplot」用於下載位置,並選擇最近的。 – 2014-09-26 08:19:33

+0

問題是我沒有生成變量。我想明白爲什麼。 – 2014-09-26 11:37:53

回答

1

如果你不需要存儲變量,cdfplot將做的伎倆。如果沒有,cumul似乎工作得很好:

sysuse auto, clear 

/* Without Storing Variables */ 
ssc install cdfplot 
cdfplot price, by(foreign) saving(cdfplot, replace) 

/* With Variable Creation */ 
cumul price if foreign == 0, gen(cprice0) 
cumul price if foreign == 1, gen(cprice1) 

tw conn cprice* price, sort connect(J J) ms(none none) saving(cumulplot, replace) 

/* Compare the two methods */ 
graph combine cdfplot.gph cumulplot.gph