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
Removing duplicate words from a string variableI have a variable with a row of ICD codes. Some of them are repeated One registration looks like thi…
Variable assigning number to dates within periodsHi. I have a dataset where I have registered observations on specific dates within a different peri…
Do I need to check for heteroscedasticity in mediation analysis?Hi everyone, I am conducting a mediation analysis using the ml_mediation command on Stata which by …
Building time windows from years, starting from most recent yearDear all, I have some panel data containing countries and years. I need to build three-year time wi…
Not recounting new CEO roleIn my dataset, a director can have different roles each year. In my example, the director gets a new…
Subscribe to:
Post Comments (Atom)
0 Response to Writing a code to identify 8-10 consecutive points below mean
Post a Comment