0

I'm trying this code (just below), Stata seems to read it -- it does not show any errors --, but it does not generate any variables. Here it is:

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

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

line cprice1 cprice2 price

Could you guys help me? I could graph two kernel density distributions with a condition of "if" for the dummy, with a similar code, in which I stored the results for latter graphing them -- following the help files in Stata. But I could not do this with the cumulative distributions.

4

1 回答 1

2

If you don't need to store the variables, cdfplot will do the trick. If not, cumul seems to work just fine:

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
于 2014-09-26T18:09:04.827 回答