Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Testing for a contiguous subset of observations?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Testing for a contiguous subset of observations?
Date   Fri, 30 Nov 2007 11:49:15 +0000 (GMT)

bys id (observation) : gen zero = Activity == 0
bys id zero (observation) : gen nzero = _N if zero == 0
replace nzero = 0 if nzero == .
gen activity2 = activity if nzero < 60 & nzero

-- Maarten

--- BW Wheeler <[email protected]> wrote:

> Dear all,
> 
> I'm having trouble figuring out a solution to this data management
> problem, 
> and have exhausted all books and findit (partly as it's hard to know
> what 
> to search for)!
> 
> I have time series data captured from accelerometers, with an
> observation 
> of 'activity counts' logged every 10 seconds for several days for
> each 
> individual. If the number of counts is zero continuously for any
> period of 
> 10 minutes or more (i.e. 60+ observations), we need to assume that
> the 
> accelerometer was not being worn, and to treat these zeros as
> missing.
> 
> So, my data look something like this:
> 
> Observation		Date		Time		Activity
> 1			13/05/2006	15:20:00	230
> 2			13/05/2006	15:20:10	215
> 3			13/05/2006	15:20:20	0
> 4			13/05/2006	15:20:30	0
> 5			13/05/2006	15:20:40	0
> ...
> 
> Does anyone have any ideas of how I can replace the 'Activity' value
> with 
> missing, if that value is a zero in the midst of a continuous series
> of 60+ 
> zeros?
> 
> Any advice very gratefully received
> Thanks,
> Ben
> 
> ----------------------
> Ben Wheeler
> Research Fellow
> Department of Social Medicine, University of Bristol
> & South West Public Health Observatory
> [email protected]
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index