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 selection for a panel: struggling with panel bootstrap in the programDear Statalisters, I am using Stata 15.1 and I would like to address the sample selection problem i…
Cleaning data of Globar Entrepreneurship MonitorDear All, I am currently dealing with cross-sectional studies derived from the Global Entrepreneurs…
How do i open one of these .dat files?https://data.nber.org/data/cps_basic.html for example March 2015 how would i open this in Stat? Than…
Survey dataGood morning I need some advice for my master thesis please. My data is a cross-sectional survey. A…
define constraints for baseoutcome in mlogitI want to estimate a mlogit model Code: mlogit depvar ibn.fvar1 othervars there are categories in m…
Subscribe to:
Post Comments (Atom)
0 Response to Writing a code to identify 8-10 consecutive points below mean
Post a Comment