Statalist


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

st: Collpasing Data by every 4 observations


From   "Michael W. Beets" <beetsm@onid.orst.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Collpasing Data by every 4 observations
Date   Wed, 21 May 2008 12:03:50 -0700

I have 15sec interval data collected on individuals over the course of a single day.

The data look like the following, where "counts" are the primary outcome and time is the "time" (fraction of 24hrs) the counts occurred.

What I am attempting to do is create a mean of every 4 15sec intervals to reflect the average counts/min. Hence, if a person is monitored (at 15sec intervals) over the duration of 1hr, they would have 240 lines of data containing counts. This needs to be collapsed into average counts/min (resulting in 60 lines of data/person).

However, I am unaware of how to specify the collapse command to take the average of every 4 lines of data.



. list counts time in 1/20

+------------------+
| counts time |
|------------------|
1. | 210 .333507 |
2. | 75 .333681 |
3. | 166 .333854 |
4. | 466 .334028 |
5. | 29 .334201 |
|------------------|
6. | 19 .334375 |
7. | 12 .334549 |
8. | 0 .334722 |
9. | 0 .334896 |
10. | 16 .335069 |
|------------------|
11. | 0 .335243 |
12. | 398 .335417 |
13. | 566 .33559 |
14. | 0 .335764 |
15. | 10 .335938 |
|------------------|
16. | 1133 .336111 |
17. | 651 .336285 |
18. | 139 .336458 |
19. | 393 .336632 |
20. | 430 .336806 |
+------------------+
r; t=0.03 12:03:12






Michael W. Beets, M.P.H., Ph.D.

Department of Public Health
Oregon State University
256 Waldo Hall
Corvallis, OR 97331-6406
PH: 541-738-2888
CELL: 541-231-6673
FAX: 541-737-4001
Email: beetsm@onid.orst.edu





*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index