[EpiData-list] How to: Time variables and Epicurves (grouping by hours)

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Wed May 7 14:59:15 CDT 2008


Christine asked how to create efficient epicurves with an X axis 
grouping in time intervals.

I think the efficient way would be to change your date/time variables 
into hours since observation or a given day. Then cut the x-axis and 
work a bit on labelling.

That might sound easier than done (would take some time of 
experimentation). But for the development plan I think we should 
consider adding easier ways of doing that. E.g. to allow epicurve to 
scale the axis with different groupings, but also to find ways of 
managing time/date situations.

Some hints to the solution could be along these lines -  A test could be:
variables:
dateonset : date of first symptom
timeonset: hour at which the symptom came on that date
(say the observations start on 1st of May this year)
case: at least one positive symptom

* generate 50 test observations and an epicurve grouped by 3:
Close
generate 50
gen d dateonset=dmy(1,5,2008)+(recnumber mod 3)
gen i timeonset = 24 mod recnumber
gen i timevar = 24*(dateonset - dmy(1,5,2008)) + timeonset
gen i case = recnumber mod 2

* epicurve by hour would then be
epicurve timevar case

* recode hours to grouped hours by 3:
define time3 ###
recode timevar to time3 by 3
tab time3

* show epicurve:
epicurve time3 case /xinc=3 /ti="Epicurve for ..... cases in 3 hour 
groups since start"

Notice that the time3 variable will have labels, but currently these are 
not added to the
graph. But for just showing the graph the lines would work.

regards Jens Lauritsen
EpiData Association



More information about the EpiData-list mailing list