Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Plot start to end dates using spike command


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Plot start to end dates using spike command
Date   Thu, 3 Oct 2013 13:33:32 +0200

On Thu, Oct 3, 2013 at 12:57 PM, Hagger-Johnson, Gareth wrote:
> I have some data in long format recording the start/end days of a period, the number of days in that period (days) and the day a separate event (eventday) occurred.
<snip>
> Is it possible to have horiztonal lines connecting the start and end days (line of length 'days')? Put differently, plot a line of length 'days' starting at 'start'?

*---------------- begin example ------------------
clear
input id      start   end     days    eventday
1       1       2       1       30
1       40      40      0       .
2       25      26      1       200
2       265     268     3       .
3       10      15      5       17
4       20      25      5       234
5       15      35      20      16
end

gen x = _n
egen xaxis = axis(id x), gap
list id x xaxis, nolabel sepby(id)

twoway rspike start end xaxis,      ///
    horizontal lwidth(thick)        ///
    ylabel(1 "1" 2 "1" 4 "2" 5 "2"  ///
           7 "3" 9 "4" 11 "5")      ///
    ytitle(id)
*----------------- end example -------------------

This requires the -egenmore- package that can be downloaded from SSC
by typing in Stata -ssc install egenmore-.

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index