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.

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
John Doe
  • 212
  • 1
  • 9
  • 28
  • The example in `help cumul` works just fine. Try that. It's difficult to figure out what is wrong if you do not give a reproducible example. – Roberto Ferrer Sep 25 '14 at 23:54
  • `distplot` from the *Stata Journal* supports cumulative distribution plots. `search distplot` in Stata for download locations, and choose the most recent. – Nick Cox Sep 26 '14 at 08:19
  • The problem is that I'm not generating the variables. I wanted to understand why. – John Doe Sep 26 '14 at 11:37
  • Our problem is that you don't give a reproducible example. – Nick Cox Sep 26 '14 at 18:15

1 Answers1

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
Nick Cox
  • 35,529
  • 6
  • 31
  • 47
dimitriy
  • 9,077
  • 2
  • 25
  • 50