Plot with multiple participants

27 views Asked by At

enter image description here

In Stata I would like to plot ve (y-axis) against hr (x-axis) for each participant in one plot. Each participant (i.e., P1, P3, ...) has different values for hr and ve. id is an extra variable.

I probably have to use the command if id==1. I tried

twoway (lowess ve hr if id==1) (lowess ve hr if id==3) (lowess ve hr if id==6) 

but I am not sure if that is correct.

Which command can I use to plot hr and ve for the different participants in one plot (like on the picture)?

1

There are 1 answers

0
Nick Cox On

if here is a qualifier, not a command. lowess smooths each y variable as a function of the x variable. I would recommend starting with a simpler line chart. Something like

line ve hr if id==1 || line ve hr if id==3 || line ve hr if id==6

is likely to be legal and may be useful. Consider also

ssc inst sepscatter 
sepscatter ve hr, sep(id) recast(line) 

Direct labelling (identifier text next to each line) is more work.