Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Moving average of hourly pollutant data


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Moving average of hourly pollutant data
Date   Wed, 28 Aug 2013 09:57:43 +0100

I assume that you have your moving averages in -pollutant-. Each
window [6, 18] can be identified by the day in which it occurs.

egen dailymax = max(pollutant / inrange(hour, 6, 18)), by(date)

Another way of writing that is

egen dailymax = max(cond(inrange(hour,6,18), pollutant, .)), by(date)




Nick
[email protected]


On 28 August 2013 09:34, Kumar Raj <[email protected]> wrote:
> I have searched the archive, but could not find a solution for my
> query. I have hourly measurement of pollutants and would like to
> calculate the maximum value of an eight hour moving average between
> 0600 hours and 1800 hours. How can I do this? I have pasted  sample
> data below.
> date time pollutant
> 30-dec-03 1 56.87
> 30-dec-03 2 56.77
> 30-dec-03 3 55.25
> 30-dec-03 4 38.43
> 30-dec-03 5 38.82
> 30-dec-03 6 48.43
> 30-dec-03 7 18.11
> 30-dec-03 8 9.61
> 30-dec-03 9 6.7
> 30-dec-03 10 6.01
> 30-dec-03 11 12.53
> 30-dec-03 12 28.11
> 30-dec-03 13 12.46
> 30-dec-03 14 18.02
> 30-dec-03 15 10.83
> 30-dec-03 16 7.77
> 30-dec-03 17 9.7
> 30-dec-03 18 6.73
> 30-dec-03 19 10.92
> 30-dec-03 20 8.89
> 30-dec-03 21 33.4
> 30-dec-03 22 38.2
> 30-dec-03 23 43.59
> 30-dec-03 24 42.78
>
>  Thanks
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index