My data comes from an observational study which measured cell counts (lymc) and brain swelling (total_pho) in 71 patients at the same time points after stroke. It measured both variables at the same 4 time points (numbered 1,2,3,4) after the stroke. I am trying to plot the 2 variables on the same graph -both variables should be line graphs and I would like the median of each variable plotted at a given time, but the y axes will have different scales. The data is in a long format (sample posted below) - and there are some missing values e.g. person 134 doesn't have cell count or brain swelling measured at times 3 and 4.
id time total_pho lymc
131 1 2.13 1.32
131 2 3.68 2.08
131 3 2.41 2.21
131 4 2.21
132 1 59.96 1.31
132 2 70.5 2.58
132 3 98.08 2.07
132 4 114.17 1.99
133 1 24.06 3.1
134 2 29.1 2.27
134 3
134 4
135 1 51.8 .79
135 2 50.43 1.11
I used this code -
graph twoway (line lymc time, yaxis(1)) (line total_pho time, yaxis(2))
It produced the graph with the correct axes but doesn't seem to recognise that the data is time series, so has produced a separate line for each separate participant.
How do I sort that? Is there also a way to plot the interquartile range for each varible at each of the time points?
thankyou
id time total_pho lymc
131 1 2.13 1.32
131 2 3.68 2.08
131 3 2.41 2.21
131 4 2.21
132 1 59.96 1.31
132 2 70.5 2.58
132 3 98.08 2.07
132 4 114.17 1.99
133 1 24.06 3.1
134 2 29.1 2.27
134 3
134 4
135 1 51.8 .79
135 2 50.43 1.11
I used this code -
graph twoway (line lymc time, yaxis(1)) (line total_pho time, yaxis(2))
It produced the graph with the correct axes but doesn't seem to recognise that the data is time series, so has produced a separate line for each separate participant.
How do I sort that? Is there also a way to plot the interquartile range for each varible at each of the time points?
thankyou
Comment