I’m working with a dataset in the long format. My observations are grouped within ids (id) and weeks (week), the combination of id and week make an observation unique. I have a probabilities (prob) that I would like to plot as a line graph for different observations. This would be done stratified (separate graphs) for different groups (group).
Please find below a mock dataset similar to what my real data looks like:
Code:
clear input long id str10 week float prob byte group 1 "1/10/2020" .14303502 2 1 "1/3/2020" .12902983 2 1 "12/20/2019" .04932104 2 1 "12/27/2019" .04299045 2 2 "1/10/2020" .1206926 1 2 "1/3/2020" .05439886 1 2 "12/20/2019" .032277483 1 2 "12/27/2019" .05520606 1 3 "1/10/2020" .1378371 1 3 "1/3/2020" .1603722 1 3 "12/20/2019" .06625363 1 3 "12/27/2019" .1458157 1 4 "1/10/2020" .11175546 1 4 "1/3/2020" .0779216 1 4 "12/20/2019" .1137393 1 4 "12/27/2019" .064635806 1 5 "1/10/2020" .09516551 1 5 "1/3/2020" .1502394 1 5 "12/20/2019" .12006584 1 5 "12/27/2019" .12520134 1 end
Code:
gen date = date(week, "MDY") sort date sencode week, gen(week2) linkplot prob week2 if group==1, link(id)
Am I overlooking something simple here? Does anyone have suggestions on how to proceed on this? I appreciate any tips or hints.
Cheers
0 Response to Multiple line plot of long data
Post a Comment