I have a data set of clients (unique ID) with their week of immunization and age group. What I would like to do is create a time series graph that displays the cumulative count over time (week of immunization), and a separate line for each age bracket.
So far, I collapsed (count) the data by age groups and episode week and then used xtline to plot the counts over time and overlay to bring the panels (age groups) into a single graph.
Where I am stuck is being able to plot the cumulative frequencies over time by age bracket. I also tried collapsing (sum) by episode week but this ignores age brackets and I'm not sure it provides cumulative frequencies. I've seen methods for cumulative distribution (values adding up to 1), but this is not what I would like to do, as I need cumulative frequencies.
Can anybody please advise on how to best set up the data to generate this time series? I've included my code below:
Code:
collapse (count) clientid_new, by (epwk agegrp) rename clientid_new count label var count "Number of persons immunized" label define agegroups 0 "0-11" 1 "12-17" 2 "18-24" 3 "25-29" 4 "30-39" 5 "40-49" 6 "50-59" 7 "60-69" 8 "70-79" 9 "80+" label define weeks 0 "13-Dec-20" 1 "20-Dec-20" 2 "27-Dec-20" 3 "03-Jan-21" 4 "10-Jan-21" 5 "17-Jan-21" 6 "24-Jan-21" 7 "31-Jan-21" 8 "07-Feb-21" 9 "14-Feb-21" 10 "21-Feb-21" 11 "28-Feb-21" 12 "07-Mar-21" 13 "14-Mar-21" 14 "21-Mar-21" 15 "28-Mar-21" 16 "04-Apr-21" 17 "11-Apr-21" 18 "18-Apr-21" 19 "25-Apr-21" 20 "02-May-21" 21 "09-May-21" 22 "16-May-21" 23 "23-May-21" 24 "30-May-21" 25 "06-Jun-21" 26 "13-Jun-21" 27 "20-Jun-21" 28 "27-Jun-21" 29 "04-Jul-21" 30 "11-Jul-21" 31 "18-Jul-21" 32 "25-Jul-21" 33 "01-Aug-21" 34 "08-Aug-21" 35 "15-Aug-21" 36 "22-Aug-21" 37 "29-Aug-21" label values agegrp agegroups label values epwk weeks tsset agegrp epwk tsfill, full replace count = 0 if missing(count) xtline count, overlay collapse (sum) count, by(epwk) tsset epwk **[stuck here]
0 Response to Creating cumulative frequency time series (overlay panels)
Post a Comment