Hi, I have a huge dataset (n=12000) with variables of interest: date and cholesterol level. For each date, there can be multiple cholesterol measurements from different participants. For example:
Date Cholesterol
24/8/2018 116.4
24/8/2018 120.5
24/8/2018. 118.5
27/8/2018. 130.7
27/8/2018. 135.8
28/8/2018. 129.8
Due to the large number of observations, I have derived average of cholesterol by batch of 100 (Y-axis) and plotted this against the Median (Date) of this batch of 100 (X-axis). Below are my code:
seq batch, f(1) t(120) b(100)
egen cholesterol_batch100 = mean (Cholesterol), by (batch)
egen median_date= median (Date), by (batch)
format median_date %td
***My question is how do I write a code to identify, say 8 consecutive points that are below the mean value of the cholesterol level. For example, the calculated average value of cholesterol for n=12000 is 140. How do I pick up a trend of 8 consecutive points measured on consecutive dates (ie. 24/8/2018, 27/8/2018/, 28/8/2018 , etc) that are below this value? I don't even know where to start. Hope to get some advice. Many thanks!
Related Posts with Writing a code to identify 8-10 consecutive points below mean
Sample 1: I have all data plus instrumental variables; Sample 2: I have all data but NOT the instrumental variables; What to do?Good morning, I am soliciting ideas of what you would do in the following situation: I have two wa…
Grand margin is ouside range given by margins at specified values of covariatesI have a problem understanding -margin results, even after reading Clyde Schechter's clarifications.…
Help! Calculate log of realised returnDear Statalister, Does someone know how to calculate log of realised return in STATA? I tried to us…
Is there code for analyzing the Dietary Screener Questionnaire in Stata?Hello, I am using the Dietary Screener Questionnaire to assess dietary intake. The National Cancer …
Reshaping to longDear all, thank you for the valuable advice you provide on this forum to all STATA newbies like me. …
Subscribe to:
Post Comments (Atom)
0 Response to Writing a code to identify 8-10 consecutive points below mean
Post a Comment